Skip to content

Test NumPy's result dtypes on the typed evaluator (follow-up to #754) - #758

Merged
FrancescAlted merged 1 commit into
Blosc:improved-miniexprfrom
FabianIsensee:typed-dtype-tests
Nov 5, 2026
Merged

FrancescAlted merged 1 commit into
Blosc:improved-miniexprfrom
FabianIsensee:typed-dtype-tests

Conversation

@FabianIsensee

Copy link
Copy Markdown
Contributor

Hi Francesc,

this follows up #754, as you asked there. Your typed evaluator supersedes #754's source change, so this PR only brings over its tests, adapted to improved-miniexpr at 7eae862, plus one strict xfail for a bug I found on the way.

What it adds (all in tests/ndarray/test_lazyexpr.py):

WebAssembly: #754 marked 30 cases as strict xfails on WASM, because there the bundled miniexpr computed them. With the typed evaluator they pass, also with blosc2.IS_WASM = True set natively, so this PR has no WASM xfails. The WASM CI job checks it on a real Pyodide build.

Legacy evaluator: with BLOSC2_EXPRESSION_EVALUATOR=legacy, 80 cases still fail: 64 give the uniform evaluator's result dtype, and 16 compute integer true division in integer arithmetic on expr[:]. They are strict xfails in legacy mode only (_LEGACY_RESULT_DTYPE_FAILURES), so the list can go when the legacy evaluator does.

Bug in the typed evaluator (strict xfail): blosc2.lazyexpr("a < 300", {"a": a}) with an int8 a raises OverflowError: Python integer 300 out of bounds for int8 on [:], compute() and .sum(), and so does a < 300. NumPy 2 compares (all True); only arithmetic with such an int raises. The error comes from expression_graph._numpy_binary_dtype(), called through native_weak_scalars_eligible(), which treats the comparison like arithmetic. The legacy evaluator casts 300 to int8 (44) instead: 144 True of 200 on [:] and compute(); its .sum() is right.

Not a bug, so not included: the float16 sums of hypot()/arctan2() of bool arrays that I had flagged match NumPy's own float16 sums to one float16 ulp (hypot: 3324 vs NumPy 3322; arctan2: equal). My earlier reproducer compared them with a float64 sum.

Tests (NumPy 2.5.4, Linux x86-64, bundled miniexpr 687e02b and c-blosc2 3.5.0):

  • New tests: default (typed) 197 passed, 15 skipped, 3 xfailed; legacy 118 passed, 15 skipped, 82 xfailed; the same with blosc2.IS_WASM = True.
  • tests/ndarray/test_lazyexpr.py: typed 1053 passed, 15 skipped, 3 xfailed; legacy 974 passed, 15 skipped, 82 xfailed.
  • Full suite: 11184 passed, 389 skipped, 3 xfailed; the 2 failures are the b2view http tests that need aiohttp.
  • ruff check and ruff format pass.
  • Not run locally: NumPy 1.x (the out-of-range test is skipped there, like the other NEP 50 tests in this file) and a real WASM build.

AI disclosure: the port, the new test and the checks were done with Claude Code; I reviewed them.

Best,
Fabian

🤖 Generated with Claude Code

The dtype tests of Blosc#754, on the typed evaluator: float functions and
true division of integer and bool subexpressions, bool //, % and **,
non-native byte order, and arctan2() rejecting complex operands. The
values of expr[:] are checked too. The WebAssembly xfails are gone; the
cases the legacy evaluator still gets wrong are strict xfails there.

New strict xfail: comparing an int8 array with 300 raises OverflowError
in the typed evaluator, while NumPy 2 compares (all True).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@FrancescAlted
FrancescAlted merged commit 2e20a37 into Blosc:improved-miniexpr Nov 5, 2026
1 check passed
@FrancescAlted

Copy link
Copy Markdown
Member

Thanks @FabianIsensee for this!

Merged into improved-miniexpr through improved-miniexpr2 (merge commit 2e20a376). The branch is now at 0d707e89 and pins miniexpr 12bf4da; it is the head of PR #741.

The combined stack passed the full test suite (12,841 passed on the default path, 12,765 on legacy) and the Menudet paired qualification, including the exact-pair wheel and tcc JIT tests (run 41998579498). Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants