|
95 | 95 | try_miniexpr = True |
96 | 96 | if blosc2.IS_WASM: |
97 | 97 | try_miniexpr = False |
98 | | -if sys.platform == "win32": |
99 | | - # Although miniexpr has support for windows, the integration with Blosc2 |
100 | | - # still has some rough edges. |
101 | | - try_miniexpr = False |
| 98 | + |
| 99 | +_MINIEXPR_WINDOWS_OVERRIDE = os.environ.get("BLOSC2_ENABLE_MINIEXPR_WINDOWS", "").strip().lower() |
| 100 | +_MINIEXPR_WINDOWS_OVERRIDE = _MINIEXPR_WINDOWS_OVERRIDE not in ("", "0", "false", "no", "off") |
102 | 101 |
|
103 | 102 |
|
104 | 103 | def ne_evaluate(expression, local_dict=None, **kwargs): |
@@ -1326,6 +1325,26 @@ def fast_eval( # noqa: C901 |
1326 | 1325 | use_miniexpr = False |
1327 | 1326 | if not (all_ndarray and out is None): |
1328 | 1327 | use_miniexpr = False |
| 1328 | + has_complex = any( |
| 1329 | + isinstance(op, blosc2.NDArray) and blosc2.isdtype(op.dtype, "complex floating") |
| 1330 | + for op in operands.values() |
| 1331 | + ) |
| 1332 | + if isinstance(expression, str) and has_complex: |
| 1333 | + if sys.platform == "win32": |
| 1334 | + # On Windows, miniexpr has issues with complex numbers |
| 1335 | + use_miniexpr = False |
| 1336 | + if any(tok in expression for tok in ("!=", "==", "<=", ">=", "<", ">")): |
| 1337 | + use_miniexpr = False |
| 1338 | + if sys.platform == "win32" and use_miniexpr and not _MINIEXPR_WINDOWS_OVERRIDE: |
| 1339 | + # Work around Windows miniexpr issues for integer outputs and dtype conversions. |
| 1340 | + if blosc2.isdtype(dtype, "integral"): |
| 1341 | + use_miniexpr = False |
| 1342 | + else: |
| 1343 | + dtype_mismatch = any( |
| 1344 | + isinstance(op, blosc2.NDArray) and op.dtype != dtype for op in operands.values() |
| 1345 | + ) |
| 1346 | + if dtype_mismatch: |
| 1347 | + use_miniexpr = False |
1329 | 1348 |
|
1330 | 1349 | if use_miniexpr: |
1331 | 1350 | cparams = kwargs.pop("cparams", blosc2.CParams()) |
@@ -2036,6 +2055,18 @@ def reduce_slices( # noqa: C901 |
2036 | 2055 | isinstance(op, blosc2.NDArray) and blosc2.isdtype(op.dtype, "complex floating") |
2037 | 2056 | for op in operands.values() |
2038 | 2057 | ) |
| 2058 | + if has_complex and sys.platform == "win32": |
| 2059 | + # On Windows, miniexpr has issues with complex numbers |
| 2060 | + use_miniexpr = False |
| 2061 | + if sys.platform == "win32" and use_miniexpr and not _MINIEXPR_WINDOWS_OVERRIDE: |
| 2062 | + if blosc2.isdtype(dtype, "integral"): |
| 2063 | + use_miniexpr = False |
| 2064 | + else: |
| 2065 | + dtype_mismatch = any( |
| 2066 | + isinstance(op, blosc2.NDArray) and op.dtype != dtype for op in operands.values() |
| 2067 | + ) |
| 2068 | + if dtype_mismatch: |
| 2069 | + use_miniexpr = False |
2039 | 2070 | if has_complex and any(tok in expression for tok in ("!=", "==", "<=", ">=", "<", ">")): |
2040 | 2071 | use_miniexpr = False |
2041 | 2072 | if where is not None and len(where) != 2: |
|
0 commit comments