Skip to content

Fix test incompatibilities with numpy 2.5 - #2376

Merged
juanitorduz merged 1 commit into
pymc-devs:mainfrom
juanitorduz:fix-numpy-2.5-test-compat
Aug 24, 2026
Merged

Fix test incompatibilities with numpy 2.5#2376
juanitorduz merged 1 commit into
pymc-devs:mainfrom
juanitorduz:fix-numpy-2.5-test-compat

Conversation

@juanitorduz

@juanitorduz juanitorduz commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Description

CI on main has been failing since numpy 2.5 was picked up (e.g. this run on main) — 8 jobs fail, all reducing to three test-side incompatibilities:

  1. tests/tensor/signal/test_conv.py::test_convolve2d (108 parametrizations, all tensor scipy+blas+pad jobs in every mode): the test seeded np.random.default_rng((172, kernel_shape, data_shape, sum(map(ord, mode)))) — a tuple containing tuples. numpy 2.5's SeedSequence rejects nested sequences with TypeError: SeedSequence does not accept nested sequences. Fixed by flattening the entropy tuple (still deterministic per parametrization).

  2. tests/tensor/test_extra_ops.py::TestSearchsortedOp::test_searchsortedOp_on_right_side (NUMBA tensor *rest jobs) and

  3. tests/link/numba/test_extra_ops.py::test_Searchsorted[a1-v1-left-None-None] (numba link job): both compared np.searchsorted against the pytensor/numba implementations on unsorted arrays. searchsorted on unsorted input is documented undefined behavior; numpy 2.5's reworked binary search now returns different (equally valid) results than numba's reimplementation, so the comparisons diverge. (CVM-mode jobs kept passing because the C implementation delegates to numpy's own routine.) Fixed by using sorted inputs — the same pattern test_searchsortedOp_on_sorted_input already uses.

Test-only changes; no library code touched. Verified locally with numpy 2.5.2: all 108 test_convolve2d params, the full TestSearchsortedOp suite, and all test_Searchsorted params pass (110 failed before).

These same failures currently show up on open PRs (e.g. #2375), where they are unrelated to the PR's changes.

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

@jessegrabowski

Copy link
Copy Markdown
Member

i'd rather people not add the claude co-author line on their commits, but I am losing this battle.

@juanitorduz

Copy link
Copy Markdown
Contributor Author

i'd rather people not add the claude co-author line on their commits, but I am losing this battle.

I can open a brand new PR (I did not know about this)

@jessegrabowski

Copy link
Copy Markdown
Member

no need, just edit the commit message and force-push

numpy 2.5 broke three tests on main (all CI jobs failing since it was
picked up):

- test_convolve2d seeded default_rng with a tuple containing the shape
  tuples; SeedSequence now raises "does not accept nested sequences".
  Flatten the seed entropy instead.
- test_searchsortedOp_on_right_side and the numba test_Searchsorted
  compared np.searchsorted against the pytensor/numba implementations on
  UNSORTED arrays. That is documented undefined behavior, and numpy 2.5's
  reworked binary search now returns different (equally valid) results
  than the C/numba implementations. Use sorted inputs.
@juanitorduz
juanitorduz force-pushed the fix-numpy-2.5-test-compat branch from 27ce089 to 176caed Compare August 24, 2026 13:37
@juanitorduz

juanitorduz commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Done: removed the co-author line and force-pushed (here and on #2375).

@jessegrabowski

Copy link
Copy Markdown
Member

thanks, feel free to merge when ci is green

@juanitorduz
juanitorduz merged commit 48e2a86 into pymc-devs:main Aug 24, 2026
67 checks passed
@juanitorduz
juanitorduz deleted the fix-numpy-2.5-test-compat branch August 24, 2026 14:24
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