Skip to content

Commit

Permalink
chore: update pre-commit hooks (#2)
Browse files Browse the repository at this point in the history
* chore: update pre-commit hooks

updates:
- [github.com/adamchainz/blacken-docs: 1.16.0 → 1.18.0](adamchainz/blacken-docs@1.16.0...1.18.0)
- [github.com/pre-commit/mirrors-prettier: v3.1.0 → v4.0.0-alpha.8](pre-commit/mirrors-prettier@v3.1.0...v4.0.0-alpha.8)
- [github.com/astral-sh/ruff-pre-commit: v0.4.1 → v0.5.1](astral-sh/ruff-pre-commit@v0.4.1...v0.5.1)
- [github.com/codespell-project/codespell: v2.2.6 → v2.3.0](codespell-project/codespell@v2.2.6...v2.3.0)
- [github.com/abravalheri/validate-pyproject: v0.16 → v0.18](abravalheri/validate-pyproject@v0.16...v0.18)
- [github.com/python-jsonschema/check-jsonschema: 0.28.2 → 0.28.6](python-jsonschema/check-jsonschema@0.28.2...0.28.6)

* fix pre-commit

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Saransh <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and Saransh-cpp authored Jul 13, 2024
1 parent 462d2ff commit 57c3606
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
rev: "1.18.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==24.*]
Expand Down Expand Up @@ -33,14 +33,14 @@ repos:
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.1"
rev: "v0.5.1"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand All @@ -56,7 +56,7 @@ repos:
# - pytest

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
rev: "v2.3.0"
hooks:
- id: codespell

Expand All @@ -74,13 +74,13 @@ repos:
exclude: .pre-commit-config.yaml

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.16"
rev: "v0.18"
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.28.2"
rev: "0.28.6"
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand Down
29 changes: 13 additions & 16 deletions src/cuda_histogram/hist_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def overflow_behavior(overflow):
elif overflow == "justnan":
return slice(-1, None)
else:
raise ValueError("Unrecognized overflow behavior: %s" % overflow)
raise ValueError(f"Unrecognized overflow behavior: {overflow}")


@functools.total_ordering
Expand Down Expand Up @@ -144,7 +144,7 @@ def __eq__(self, other):
return False
if other.nan() and self.nan():
return True
if self._lo == other._lo and self._hi == other._hi:
if self._lo == other._lo and self._hi == other._hi: # noqa: SIM103
return True
return False

Expand Down Expand Up @@ -195,7 +195,7 @@ class StringBin:
def __init__(self, name, label=None):
if not isinstance(name, basestring):
raise TypeError(
"StringBin only supports string categories, received a %r" % name
f"StringBin only supports string categories, received a {name!r}"
)
elif "*" in name:
raise ValueError(
Expand Down Expand Up @@ -269,16 +269,14 @@ def label(self, label):

def __eq__(self, other):
if isinstance(other, Axis):
if self._name != other._name:
if self._name != other._name: # noqa: SIM103
return False
# label doesn't matter
return True
elif isinstance(other, basestring):
# Convenient for testing axis in list by name
if self._name != other:
return False
return True
raise TypeError("Cannot compare an Axis with a %r" % other)
return not self._name != other
raise TypeError(f"Cannot compare an Axis with a {other!r}")


class SparseAxis(Axis):
Expand Down Expand Up @@ -356,7 +354,7 @@ def __eq__(self, other):

def __getitem__(self, index):
if not isinstance(index, StringBin):
raise TypeError("Expected a StringBin object, got: %r" % index)
raise TypeError(f"Expected a StringBin object, got: {index!r}")
identifier = index.name
if identifier not in self._bins:
raise KeyError("No identifier %r in this Category axis")
Expand All @@ -375,7 +373,7 @@ def _ireduce(self, the_slice):
elif isinstance(the_slice, list):
if not all(k in self._sorted for k in the_slice):
warnings.warn(
"Not all requested indices present in %r" % self, RuntimeWarning
f"Not all requested indices present in {self!r}", RuntimeWarning
)
out = [k for k in self._sorted if k in the_slice]
elif isinstance(the_slice, slice):
Expand Down Expand Up @@ -419,7 +417,7 @@ def sorting(self, newsorting):
# this will be checked in any Hist.identifiers() call accessing this axis
pass
else:
raise AttributeError("Invalid axis sorting type: %s" % newsorting)
raise AttributeError(f"Invalid axis sorting type: {newsorting}")
self._sorting = newsorting

def identifiers(self):
Expand Down Expand Up @@ -501,7 +499,7 @@ def __init__(self, name, label, n_or_arr, lo=None, hi=None):
self._bin_names = np.full(self._interval_bins[:-1].size, None)
else:
raise TypeError(
"Cannot understand n_or_arr (nbins or binning array) type %r" % n_or_arr
f"Cannot understand n_or_arr (nbins or binning array) type {n_or_arr!r}"
)

@property
Expand Down Expand Up @@ -603,7 +601,7 @@ def __eq__(self, other):
return False
if self._uniform and self._bins != other._bins:
return False
if not self._uniform and not all(self._bins == other._bins):
if not self._uniform and not all(self._bins == other._bins): # noqa: SIM103
return False
return True
return super().__eq__(other)
Expand Down Expand Up @@ -1028,16 +1026,15 @@ def compatible(self, other):
d.name for d in other.sparse_axes()
}:
return False
if not all(d1 == d2 for d1, d2 in zip(self.dense_axes(), other.dense_axes())):
if not all(d1 == d2 for d1, d2 in zip(self.dense_axes(), other.dense_axes())): # noqa: SIM103
return False
return True

def add(self, other):
"""Add another histogram into this one, in-place"""
if not self.compatible(other):
raise ValueError(
"Cannot add this histogram with histogram %r of dissimilar dimensions"
% other
f"Cannot add this histogram with histogram {other!r} of dissimilar dimensions"
)

raxes = other.sparse_axes()
Expand Down
8 changes: 4 additions & 4 deletions src/cuda_histogram/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def plot1d(
raise ValueError("Cannot use density and binwnorm at the same time!")
if binwnorm is not None and not isinstance(binwnorm, numbers.Number):
raise ValueError(
"Bin width normalization not a number, but a %r" % binwnorm.__class__
f"Bin width normalization not a number, but a {binwnorm.__class__!r}"
)
if line_opts is None and fill_opts is None and error_opts is None:
if stack:
Expand Down Expand Up @@ -447,7 +447,7 @@ def plotratio(
normal_interval(sumw_num, sumw_denom, sumw2_num, sumw2_denom)
)
else:
raise ValueError("Unrecognized uncertainty option: %r" % unc)
raise ValueError(f"Unrecognized uncertainty option: {unc!r}")

if error_opts is not None:
opts = {"label": label, "linestyle": "none"}
Expand Down Expand Up @@ -546,7 +546,7 @@ def plot2d(
raise ValueError("Cannot use density and binwnorm at the same time!")
if binwnorm is not None and not isinstance(binwnorm, numbers.Number):
raise ValueError(
"Bin width normalization not a number, but a %r" % binwnorm.__class__
f"Bin width normalization not a number, but a {binwnorm.__class__!r}"
)
if patch_opts is None and text_opts is None:
patch_opts = {}
Expand Down Expand Up @@ -666,7 +666,7 @@ def plotgrid(
"More than one dimension left: {}".format(",".join(ax for ax in haxes))
)
elif len(haxes) == 0:
raise ValueError("Not enough dimensions available in %r" % h)
raise ValueError(f"Not enough dimensions available in {h!r}")

figsize = plt.rcParams["figure.figsize"]
figsize = figsize[0] * max(ncol, 1), figsize[1] * max(nrow, 1)
Expand Down

0 comments on commit 57c3606

Please sign in to comment.