@@ -116,7 +116,7 @@ def ne_evaluate(expression, local_dict=None, **kwargs):
116116constructors = ("arange" , "linspace" , "fromiter" , "zeros" , "ones" , "empty" , "full" , "frombuffer" )
117117# Note that, as reshape is accepted as a method too, it should always come last in the list
118118constructors += ("reshape" ,)
119- reducers = ("sum" , "prod" , "min" , "max" , "std" , "mean" , "var" , "any" , "all" )
119+ reducers = ("sum" , "prod" , "min" , "max" , "std" , "mean" , "var" , "any" , "all" , "slice" )
120120
121121functions = [
122122 "sin" ,
@@ -551,7 +551,20 @@ def compute_smaller_slice(larger_shape, smaller_shape, larger_slice):
551551_blacklist_re = re .compile ("|" .join (validation_patterns ))
552552
553553# Define valid method names
554- valid_methods = {"sum" , "prod" , "min" , "max" , "std" , "mean" , "var" , "any" , "all" , "where" , "reshape" }
554+ valid_methods = {
555+ "sum" ,
556+ "prod" ,
557+ "min" ,
558+ "max" ,
559+ "std" ,
560+ "mean" ,
561+ "var" ,
562+ "any" ,
563+ "all" ,
564+ "where" ,
565+ "reshape" ,
566+ "slice" ,
567+ }
555568valid_methods |= {"int8" , "int16" , "int32" , "int64" , "uint8" , "uint16" , "uint32" , "uint64" }
556569valid_methods |= {"float32" , "float64" , "complex64" , "complex128" }
557570valid_methods |= {"bool" , "str" , "bytes" }
@@ -2534,6 +2547,7 @@ def find_args(expr):
25342547 def _compute_expr (self , item , kwargs ): # noqa: C901
25352548 if any (method in self .expression for method in reducers ):
25362549 # We have reductions in the expression (probably coming from a string lazyexpr)
2550+ # Also includes slice
25372551 _globals = get_expr_globals (self .expression )
25382552 lazy_expr = eval (self .expression , _globals , self .operands )
25392553 if not isinstance (lazy_expr , blosc2 .LazyExpr ):
0 commit comments