@@ -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
284282class 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 ()
0 commit comments