@@ -75,8 +75,8 @@ def _fill_cast(value: T, *, inner: bool = False) -> Union[T, np.ndarray, Tuple[T
7575
7676
7777def _arg_shortcut (item : Union [Tuple [int , float , float ], Axis , CppAxis ]) -> CppAxis :
78- msg = "Developer shortcut: will be removed in a future version"
7978 if isinstance (item , tuple ) and len (item ) == 3 :
79+ msg = "Developer shortcut: will be removed in a future version"
8080 warnings .warn (msg , FutureWarning )
8181 return _core .axis .regular_uoflow (item [0 ], item [1 ], item [2 ]) # type: ignore
8282 elif isinstance (item , Axis ):
@@ -364,10 +364,10 @@ def _compute_inplace_op(
364364 len (other .shape ), self .ndim
365365 )
366366 )
367- elif all (( a == b or a == 1 ) for a , b in zip (other .shape , self .shape )):
367+ elif all (a in { b , 1 } for a , b in zip (other .shape , self .shape )):
368368 view = self .view (flow = False )
369369 getattr (view , name )(other )
370- elif all (( a == b or a == 1 ) for a , b in zip (other .shape , self .axes .extent )):
370+ elif all (a in { b , 1 } for a , b in zip (other .shape , self .axes .extent )):
371371 view = self .view (flow = True )
372372 getattr (view , name )(other )
373373 else :
@@ -494,13 +494,11 @@ def __str__(self) -> str:
494494 """
495495 # TODO check the terminal width and adjust the presentation
496496 # only use for 1D, fall back to repr for ND
497- if self ._hist .rank () == 1 :
498- s = str (self ._hist )
499- # get rid of first line and last character
500- s = s [s .index ("\n " ) + 1 : - 1 ]
501- else :
502- s = repr (self )
503- return s
497+ if self ._hist .rank () != 1 :
498+ return repr (self )
499+ s = str (self ._hist )
500+ # get rid of first line and last character
501+ return s [s .index ("\n " ) + 1 : - 1 ]
504502
505503 def _axis (self , i : int = 0 ) -> Axis :
506504 """
@@ -547,15 +545,14 @@ def __setstate__(self, state: Any) -> None:
547545 msg = "Cannot open boost-histogram pickle v{}" .format (state [0 ])
548546 raise RuntimeError (msg )
549547
550- self .axes = self ._generate_axes_ ()
551-
552548 else : # Classic (0.10 and before) state
553549 self ._hist = state ["_hist" ]
554550 self ._variance_known = True
555551 self .metadata = state .get ("metadata" , None )
556552 for i in range (self ._hist .rank ()):
557553 self ._hist .axis (i ).metadata = {"metadata" : self ._hist .axis (i ).metadata }
558- self .axes = self ._generate_axes_ ()
554+
555+ self .axes = self ._generate_axes_ ()
559556
560557 def __repr__ (self ) -> str :
561558 newline = "\n "
@@ -779,14 +776,13 @@ def __getitem__( # noqa: C901
779776
780777 if not integrations :
781778 return self ._new_hist (reduced )
782- else :
783- projections = [i for i in range (self .ndim ) if i not in integrations ]
779+ projections = [i for i in range (self .ndim ) if i not in integrations ]
784780
785- return (
786- self ._new_hist (reduced .project (* projections ))
787- if projections
788- else reduced .sum (flow = True )
789- )
781+ return (
782+ self ._new_hist (reduced .project (* projections ))
783+ if projections
784+ else reduced .sum (flow = True )
785+ )
790786
791787 def __setitem__ (
792788 self , index : IndexingExpr , value : Union [ArrayLike , Accumulator ]
0 commit comments