@@ -1238,6 +1238,9 @@ def fast_eval( # noqa: C901
12381238 ne_args = {}
12391239 dtype = kwargs .pop ("dtype" , None )
12401240 where : dict | None = kwargs .pop ("_where_args" , None )
1241+ if where is not None :
1242+ # miniexpr does not support where(); use the regular path.
1243+ use_miniexpr = False
12411244 if isinstance (out , blosc2 .NDArray ):
12421245 # If 'out' has been passed, and is a NDArray, use it as the base array
12431246 basearr = out
@@ -1290,15 +1293,17 @@ def fast_eval( # noqa: C901
12901293 use_miniexpr = False
12911294
12921295 if use_miniexpr :
1296+ op_dtypes = {op .dtype for op in operands .values () if isinstance (op , blosc2 .NDArray )}
1297+ if len (op_dtypes ) > 1 :
1298+ use_miniexpr = False
1299+ # Avoid padding issues except for 1D arrays (contiguous along the only axis).
1300+ if len (shape ) != 1 and builtins .any (s % c != 0 for s , c in zip (shape , chunks , strict = True )):
1301+ use_miniexpr = False
12931302 for op in operands .values ():
12941303 # Only NDArray in-memory operands
12951304 if not (isinstance (op , blosc2 .NDArray ) and op .urlpath is None and out is None ):
12961305 use_miniexpr = False
12971306 break
1298- # Check that partitions are well-behaved (no padding)
1299- if not blosc2 .are_partitions_behaved (op .shape , op .chunks , op .blocks ):
1300- use_miniexpr = False
1301- break
13021307 # Ensure blocks fit exactly in chunks
13031308 blocks_fit = builtins .all (c % b == 0 for c , b in zip (op .chunks , op .blocks , strict = True ))
13041309 if not blocks_fit :
@@ -1310,7 +1315,7 @@ def fast_eval( # noqa: C901
13101315 # All values will be overwritten, so we can use an uninitialized array
13111316 res_eval = blosc2 .uninit (shape , dtype , chunks = chunks , blocks = blocks , cparams = cparams , ** kwargs )
13121317 try :
1313- # print("expr->miniexpr:", expression)
1318+ print ("expr->miniexpr:" , expression )
13141319 res_eval ._set_pref_expr (expression , operands )
13151320 # Data to compress is fetched from operands, so it can be uninitialized here
13161321 data = np .empty (res_eval .schunk .chunksize , dtype = np .uint8 )
@@ -2001,6 +2006,16 @@ def reduce_slices( # noqa: C901
20012006
20022007 # Only behaved partitions are supported in miniexpr reductions
20032008 if use_miniexpr :
2009+ # Avoid padding issues except for 1D arrays (contiguous along the only axis).
2010+ if len (shape ) != 1 and builtins .any (s % c != 0 for s , c in zip (shape , chunks , strict = True )):
2011+ use_miniexpr = False
2012+ if use_miniexpr and isinstance (expression , str ):
2013+ has_complex = any (
2014+ isinstance (op , blosc2 .NDArray ) and blosc2 .isdtype (op .dtype , "complex floating" )
2015+ for op in operands .values ()
2016+ )
2017+ if has_complex and any (tok in expression for tok in ("!=" , "==" , "<=" , ">=" , "<" , ">" )):
2018+ use_miniexpr = False
20042019 for op in operands .values ():
20052020 # Check that chunksize is multiple of blocksize and blocks fit exactly in chunks
20062021 blocks_fit = builtins .all (c % b == 0 for c , b in zip (op .chunks , op .blocks , strict = True ))
0 commit comments