Skip to content

Commit 57c3606

Browse files
chore: update pre-commit hooks (#2)
* 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 <saransh0701@gmail.com>
1 parent 462d2ff commit 57c3606

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44

55
repos:
66
- repo: https://github.com/adamchainz/blacken-docs
7-
rev: "1.16.0"
7+
rev: "1.18.0"
88
hooks:
99
- id: blacken-docs
1010
additional_dependencies: [black==24.*]
@@ -33,14 +33,14 @@ repos:
3333
- id: rst-inline-touching-normal
3434

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

4242
- repo: https://github.com/astral-sh/ruff-pre-commit
43-
rev: "v0.4.1"
43+
rev: "v0.5.1"
4444
hooks:
4545
- id: ruff
4646
args: ["--fix", "--show-fixes"]
@@ -56,7 +56,7 @@ repos:
5656
# - pytest
5757

5858
- repo: https://github.com/codespell-project/codespell
59-
rev: "v2.2.6"
59+
rev: "v2.3.0"
6060
hooks:
6161
- id: codespell
6262

@@ -74,13 +74,13 @@ repos:
7474
exclude: .pre-commit-config.yaml
7575

7676
- repo: https://github.com/abravalheri/validate-pyproject
77-
rev: "v0.16"
77+
rev: "v0.18"
7878
hooks:
7979
- id: validate-pyproject
8080
additional_dependencies: ["validate-pyproject-schema-store[all]"]
8181

8282
- repo: https://github.com/python-jsonschema/check-jsonschema
83-
rev: "0.28.2"
83+
rev: "0.28.6"
8484
hooks:
8585
- id: check-dependabot
8686
- id: check-github-workflows

src/cuda_histogram/hist_tools.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def overflow_behavior(overflow):
8383
elif overflow == "justnan":
8484
return slice(-1, None)
8585
else:
86-
raise ValueError("Unrecognized overflow behavior: %s" % overflow)
86+
raise ValueError(f"Unrecognized overflow behavior: {overflow}")
8787

8888

8989
@functools.total_ordering
@@ -144,7 +144,7 @@ def __eq__(self, other):
144144
return False
145145
if other.nan() and self.nan():
146146
return True
147-
if self._lo == other._lo and self._hi == other._hi:
147+
if self._lo == other._lo and self._hi == other._hi: # noqa: SIM103
148148
return True
149149
return False
150150

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

270270
def __eq__(self, other):
271271
if isinstance(other, Axis):
272-
if self._name != other._name:
272+
if self._name != other._name: # noqa: SIM103
273273
return False
274274
# label doesn't matter
275275
return True
276276
elif isinstance(other, basestring):
277277
# Convenient for testing axis in list by name
278-
if self._name != other:
279-
return False
280-
return True
281-
raise TypeError("Cannot compare an Axis with a %r" % other)
278+
return not self._name != other
279+
raise TypeError(f"Cannot compare an Axis with a {other!r}")
282280

283281

284282
class SparseAxis(Axis):
@@ -356,7 +354,7 @@ def __eq__(self, other):
356354

357355
def __getitem__(self, index):
358356
if not isinstance(index, StringBin):
359-
raise TypeError("Expected a StringBin object, got: %r" % index)
357+
raise TypeError(f"Expected a StringBin object, got: {index!r}")
360358
identifier = index.name
361359
if identifier not in self._bins:
362360
raise KeyError("No identifier %r in this Category axis")
@@ -375,7 +373,7 @@ def _ireduce(self, the_slice):
375373
elif isinstance(the_slice, list):
376374
if not all(k in self._sorted for k in the_slice):
377375
warnings.warn(
378-
"Not all requested indices present in %r" % self, RuntimeWarning
376+
f"Not all requested indices present in {self!r}", RuntimeWarning
379377
)
380378
out = [k for k in self._sorted if k in the_slice]
381379
elif isinstance(the_slice, slice):
@@ -419,7 +417,7 @@ def sorting(self, newsorting):
419417
# this will be checked in any Hist.identifiers() call accessing this axis
420418
pass
421419
else:
422-
raise AttributeError("Invalid axis sorting type: %s" % newsorting)
420+
raise AttributeError(f"Invalid axis sorting type: {newsorting}")
423421
self._sorting = newsorting
424422

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

507505
@property
@@ -603,7 +601,7 @@ def __eq__(self, other):
603601
return False
604602
if self._uniform and self._bins != other._bins:
605603
return False
606-
if not self._uniform and not all(self._bins == other._bins):
604+
if not self._uniform and not all(self._bins == other._bins): # noqa: SIM103
607605
return False
608606
return True
609607
return super().__eq__(other)
@@ -1028,16 +1026,15 @@ def compatible(self, other):
10281026
d.name for d in other.sparse_axes()
10291027
}:
10301028
return False
1031-
if not all(d1 == d2 for d1, d2 in zip(self.dense_axes(), other.dense_axes())):
1029+
if not all(d1 == d2 for d1, d2 in zip(self.dense_axes(), other.dense_axes())): # noqa: SIM103
10321030
return False
10331031
return True
10341032

10351033
def add(self, other):
10361034
"""Add another histogram into this one, in-place"""
10371035
if not self.compatible(other):
10381036
raise ValueError(
1039-
"Cannot add this histogram with histogram %r of dissimilar dimensions"
1040-
% other
1037+
f"Cannot add this histogram with histogram {other!r} of dissimilar dimensions"
10411038
)
10421039

10431040
raxes = other.sparse_axes()

src/cuda_histogram/plot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def plot1d(
216216
raise ValueError("Cannot use density and binwnorm at the same time!")
217217
if binwnorm is not None and not isinstance(binwnorm, numbers.Number):
218218
raise ValueError(
219-
"Bin width normalization not a number, but a %r" % binwnorm.__class__
219+
f"Bin width normalization not a number, but a {binwnorm.__class__!r}"
220220
)
221221
if line_opts is None and fill_opts is None and error_opts is None:
222222
if stack:
@@ -447,7 +447,7 @@ def plotratio(
447447
normal_interval(sumw_num, sumw_denom, sumw2_num, sumw2_denom)
448448
)
449449
else:
450-
raise ValueError("Unrecognized uncertainty option: %r" % unc)
450+
raise ValueError(f"Unrecognized uncertainty option: {unc!r}")
451451

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

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

0 commit comments

Comments
 (0)