@@ -116,7 +116,7 @@ def ne_evaluate(expression, local_dict=None, **kwargs):
116
116
constructors = ("arange" , "linspace" , "fromiter" , "zeros" , "ones" , "empty" , "full" , "frombuffer" )
117
117
# Note that, as reshape is accepted as a method too, it should always come last in the list
118
118
constructors += ("reshape" ,)
119
- reducers = ("sum" , "prod" , "min" , "max" , "std" , "mean" , "var" , "any" , "all" )
119
+ reducers = ("sum" , "prod" , "min" , "max" , "std" , "mean" , "var" , "any" , "all" , "slice" )
120
120
121
121
functions = [
122
122
"sin" ,
@@ -551,7 +551,20 @@ def compute_smaller_slice(larger_shape, smaller_shape, larger_slice):
551
551
_blacklist_re = re .compile ("|" .join (validation_patterns ))
552
552
553
553
# 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
+ }
555
568
valid_methods |= {"int8" , "int16" , "int32" , "int64" , "uint8" , "uint16" , "uint32" , "uint64" }
556
569
valid_methods |= {"float32" , "float64" , "complex64" , "complex128" }
557
570
valid_methods |= {"bool" , "str" , "bytes" }
@@ -2534,6 +2547,7 @@ def find_args(expr):
2534
2547
def _compute_expr (self , item , kwargs ): # noqa: C901
2535
2548
if any (method in self .expression for method in reducers ):
2536
2549
# We have reductions in the expression (probably coming from a string lazyexpr)
2550
+ # Also includes slice
2537
2551
_globals = get_expr_globals (self .expression )
2538
2552
lazy_expr = eval (self .expression , _globals , self .operands )
2539
2553
if not isinstance (lazy_expr , blosc2 .LazyExpr ):
0 commit comments