Skip to content

Commit 0e43e92

Browse files
committed
Fix for windows
1 parent 3eb6053 commit 0e43e92

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/blosc2/lazyexpr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,9 +1408,10 @@ def fast_eval( # noqa: C901
14081408
and not operands_miniexpr
14091409
):
14101410
dummy_name = "__me_dummy0"
1411+
dummy_dtype = dtype if dtype is not None else np.uint8
14111412
expr_string_miniexpr = _inject_dummy_param_for_zero_input_dsl(expr_string_miniexpr, dummy_name)
14121413
operands_miniexpr = {
1413-
dummy_name: blosc2.zeros(shape, dtype=np.uint8, chunks=chunks, blocks=blocks)
1414+
dummy_name: blosc2.zeros(shape, dtype=dummy_dtype, chunks=chunks, blocks=blocks)
14141415
}
14151416
if math.prod(shape) <= 1:
14161417
# Avoid miniexpr for scalar-like outputs; current prefilter path is unstable here.

tests/ndarray/test_dsl_kernels.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,23 @@ def test_dsl_kernel_with_no_inputs_requires_shape_or_out():
219219
_ = blosc2.lazyudf(kernel_index_ramp_no_inputs, (), dtype=np.float32)
220220

221221

222+
def test_dsl_kernel_with_no_inputs_handles_windows_dtype_policy(monkeypatch):
223+
if blosc2.IS_WASM:
224+
pytest.skip("miniexpr fast path is not available on WASM")
225+
226+
import importlib
227+
228+
lazyexpr_mod = importlib.import_module("blosc2.lazyexpr")
229+
monkeypatch.setattr(lazyexpr_mod.sys, "platform", "win32")
230+
monkeypatch.setattr(lazyexpr_mod, "_MINIEXPR_WINDOWS_OVERRIDE", False)
231+
232+
shape = (10, 10)
233+
expr = blosc2.lazyudf(kernel_index_ramp_no_inputs, (), dtype=np.float32, shape=shape)
234+
res = expr[:]
235+
expected = np.arange(np.prod(shape), dtype=np.float32).reshape(shape)
236+
np.testing.assert_equal(res, expected)
237+
238+
222239
def test_dsl_kernel_index_symbols_float_cast_matches_expected_ramp():
223240
shape = (32, 5)
224241
x2 = blosc2.zeros(shape, dtype=np.float32)

0 commit comments

Comments
 (0)