@@ -657,7 +657,7 @@ def conserve_functions( # noqa: C901
657657 expression : str ,
658658 operands_old : dict [str , blosc2 .NDArray | blosc2 .LazyExpr ],
659659 operands_new : dict [str , blosc2 .NDArray | blosc2 .LazyExpr ],
660- ) -> tuple ( str , dict [str , blosc2 .NDArray ]) :
660+ ) -> tuple [ str , dict [str , blosc2 .NDArray ]] :
661661 """
662662 Given an expression in string form, return its operands.
663663
@@ -738,8 +738,6 @@ def visit_Name(self, node):
738738 node .id = newexpr .replace (";" , "" )
739739 else :
740740 node .id = self .update_func (localop )
741- else :
742- pass
743741 self .generic_visit (node )
744742
745743 def visit_Call (self , node ):
@@ -784,7 +782,7 @@ def convert_to_slice(expression):
784782 slicer = str (slicer )
785783 # use slice so that lazyexpr uses blosc arrays internally
786784 # (and doesn't decompress according to getitem syntax)
787- new_expr += ".slice(" + slicer + " )"
785+ new_expr += f ".slice({ slicer } )"
788786 skip_to_char = i + k + 1
789787 else :
790788 new_expr += expr_i
@@ -833,11 +831,11 @@ def extract_numpy_scalars(expr: str):
833831
834832def validate_inputs (inputs : dict , out = None , reduce = False ) -> tuple : # noqa: C901
835833 """Validate the inputs for the expression."""
836- if len ( inputs ) == 0 :
834+ if not inputs :
837835 if out is None :
838836 raise ValueError (
839837 "You really want to pass at least one input or one output for building a LazyArray."
840- " Maybe you want blosc2.empty() instead?"
838+ " Maybe you want blosc2.empty() instead?"
841839 )
842840 if isinstance (out , blosc2 .NDArray ):
843841 return out .shape , out .chunks , out .blocks , True
@@ -854,7 +852,7 @@ def validate_inputs(inputs: dict, out=None, reduce=False) -> tuple: # noqa: C90
854852
855853 # More checks specific of NDArray inputs
856854 NDinputs = [input for input in inputs if hasattr (input , "chunks" )]
857- if len ( NDinputs ) == 0 :
855+ if not NDinputs :
858856 # All inputs are NumPy arrays, so we cannot take the fast path
859857 if inputs and hasattr (inputs [0 ], "shape" ):
860858 shape = inputs [0 ].shape
@@ -895,7 +893,7 @@ def is_full_slice(item):
895893 elif isinstance (item , int | bool ):
896894 return False
897895 else :
898- return item == slice (None , None , None ) or item == Ellipsis
896+ return item in ( slice (None , None , None ), Ellipsis )
899897
900898
901899def do_slices_intersect (slice1 : list | tuple , slice2 : list | tuple ) -> bool :
@@ -1925,7 +1923,7 @@ def fuse_expressions(expr, new_base, dup_op):
19251923 if i < skip_to_char :
19261924 continue
19271925 if expr_i == "o" :
1928- if i > 0 and ( expr [i - 1 ] != " " and expr [ i - 1 ] != "(" ) :
1926+ if i > 0 and expr [i - 1 ] not in { " " , "(" } :
19291927 # Not a variable
19301928 new_expr += expr_i
19311929 continue
@@ -2960,18 +2958,18 @@ def info(self):
29602958
29612959 @property
29622960 def info_items (self ):
2963- items = []
2964- items += [("type" , f"{ self .__class__ .__name__ } " )]
29652961 inputs = {}
29662962 for key , value in self .inputs_dict .items ():
29672963 if isinstance (value , np .ndarray | blosc2 .NDArray | blosc2 .C2Array ):
29682964 inputs [key ] = f"<{ value .__class__ .__name__ } > { value .shape } { value .dtype } "
29692965 else :
29702966 inputs [key ] = str (value )
2971- items += [("inputs" , inputs )]
2972- items += [("shape" , self .shape )]
2973- items += [("dtype" , self .dtype )]
2974- return items
2967+ return [
2968+ ("type" , f"{ self .__class__ .__name__ } " ),
2969+ ("inputs" , inputs ),
2970+ ("shape" , self .shape ),
2971+ ("dtype" , self .dtype ),
2972+ ]
29752973
29762974 # TODO: indices and sort are repeated in LazyExpr; refactor
29772975 def indices (self , order : str | list [str ] | None = None ) -> blosc2 .LazyArray :
0 commit comments