@@ -83,7 +83,7 @@ def overflow_behavior(overflow):
83
83
elif overflow == "justnan" :
84
84
return slice (- 1 , None )
85
85
else :
86
- raise ValueError ("Unrecognized overflow behavior: %s" % overflow )
86
+ raise ValueError (f "Unrecognized overflow behavior: { overflow } " )
87
87
88
88
89
89
@functools .total_ordering
@@ -144,7 +144,7 @@ def __eq__(self, other):
144
144
return False
145
145
if other .nan () and self .nan ():
146
146
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
148
148
return True
149
149
return False
150
150
@@ -195,7 +195,7 @@ class StringBin:
195
195
def __init__ (self , name , label = None ):
196
196
if not isinstance (name , basestring ):
197
197
raise TypeError (
198
- "StringBin only supports string categories, received a %r" % name
198
+ f "StringBin only supports string categories, received a { name !r } "
199
199
)
200
200
elif "*" in name :
201
201
raise ValueError (
@@ -269,16 +269,14 @@ def label(self, label):
269
269
270
270
def __eq__ (self , other ):
271
271
if isinstance (other , Axis ):
272
- if self ._name != other ._name :
272
+ if self ._name != other ._name : # noqa: SIM103
273
273
return False
274
274
# label doesn't matter
275
275
return True
276
276
elif isinstance (other , basestring ):
277
277
# 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} " )
282
280
283
281
284
282
class SparseAxis (Axis ):
@@ -356,7 +354,7 @@ def __eq__(self, other):
356
354
357
355
def __getitem__ (self , index ):
358
356
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 } " )
360
358
identifier = index .name
361
359
if identifier not in self ._bins :
362
360
raise KeyError ("No identifier %r in this Category axis" )
@@ -375,7 +373,7 @@ def _ireduce(self, the_slice):
375
373
elif isinstance (the_slice , list ):
376
374
if not all (k in self ._sorted for k in the_slice ):
377
375
warnings .warn (
378
- "Not all requested indices present in %r" % self , RuntimeWarning
376
+ f "Not all requested indices present in { self !r } " , RuntimeWarning
379
377
)
380
378
out = [k for k in self ._sorted if k in the_slice ]
381
379
elif isinstance (the_slice , slice ):
@@ -419,7 +417,7 @@ def sorting(self, newsorting):
419
417
# this will be checked in any Hist.identifiers() call accessing this axis
420
418
pass
421
419
else :
422
- raise AttributeError ("Invalid axis sorting type: %s" % newsorting )
420
+ raise AttributeError (f "Invalid axis sorting type: { newsorting } " )
423
421
self ._sorting = newsorting
424
422
425
423
def identifiers (self ):
@@ -501,7 +499,7 @@ def __init__(self, name, label, n_or_arr, lo=None, hi=None):
501
499
self ._bin_names = np .full (self ._interval_bins [:- 1 ].size , None )
502
500
else :
503
501
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 } "
505
503
)
506
504
507
505
@property
@@ -603,7 +601,7 @@ def __eq__(self, other):
603
601
return False
604
602
if self ._uniform and self ._bins != other ._bins :
605
603
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
607
605
return False
608
606
return True
609
607
return super ().__eq__ (other )
@@ -1028,16 +1026,15 @@ def compatible(self, other):
1028
1026
d .name for d in other .sparse_axes ()
1029
1027
}:
1030
1028
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
1032
1030
return False
1033
1031
return True
1034
1032
1035
1033
def add (self , other ):
1036
1034
"""Add another histogram into this one, in-place"""
1037
1035
if not self .compatible (other ):
1038
1036
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"
1041
1038
)
1042
1039
1043
1040
raxes = other .sparse_axes ()
0 commit comments