Skip to content

fix: typetracer nplike's all function leads to infinite recursion for axis=None#3765

Merged
pfackeldey merged 4 commits intoscikit-hep:mainfrom
ikrommyd:fix-typetracer-all-function
Dec 12, 2025
Merged

fix: typetracer nplike's all function leads to infinite recursion for axis=None#3765
pfackeldey merged 4 commits intoscikit-hep:mainfrom
ikrommyd:fix-typetracer-all-function

Conversation

@ikrommyd
Copy link
Copy Markdown
Collaborator

The typetracer nplike's all function with axis=None calls itself again with axis=None leading into an infinite recursion naturally. This appears to be a typo. I think the point was when this was implemented to flatten the input with the self.reshape(x, (-1,) and then call it on the only existing axis which would be 0.

@ikrommyd ikrommyd requested a review from pfackeldey December 11, 2025 00:09
@ikrommyd
Copy link
Copy Markdown
Collaborator Author

@pfackeldey just a small typo looks like that I found when looking for something else.

@ikrommyd
Copy link
Copy Markdown
Collaborator Author

This now works

In [1]: import awkward as ak

In [2]: import numpy as np

In [3]: buffer = ak._nplikes.typetracer.TypeTracerArray._new(np.dtype("int32"), (4,))

In [4]: nplike = ak._nplikes.typetracer.TypeTracer.instance()

In [5]: nplike.all(buffer)
Out[5]: TypeTracerArray(dtype('bool'), shape=())

while on main it gives RecursionError: maximum recursion depth exceeded

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.73%. Comparing base (b749e49) to head (5b66b5c).
⚠️ Report is 489 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
src/awkward/_nplikes/typetracer.py 77.31% <ø> (+2.45%) ⬆️

... and 199 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown

The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR3765

Copy link
Copy Markdown
Collaborator

@pfackeldey pfackeldey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ikrommyd!

Yes, this is correct. The .reshape(x, (-1,)) completely flattens the typetracer array. Once it is flat we can safely call .all with axis=0, otherwise this path infinitely recurses. This solution also solves this bug for .any as it uses .all under-the-hood.

I suppose this hasn't been observed in user code so far because ak.all normalizes the axis into an int always (afaik) which then avoids the axis=None case. We should anyway fix it like you suggest.

Please add a simple test (e.g. your reproducer and a .any-case), and then it's ready for merge 👍

@ianna ianna added the pr-next-release Required for the next release label Dec 11, 2025
@ikrommyd
Copy link
Copy Markdown
Collaborator Author

Tests added @pfackeldey. This should be good to go from my side so if you agree just merge it.

Copy link
Copy Markdown
Collaborator

@pfackeldey pfackeldey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ikrommyd, LGTM!

@pfackeldey pfackeldey merged commit 0ad8b1e into scikit-hep:main Dec 12, 2025
37 of 39 checks passed
@ikrommyd ikrommyd deleted the fix-typetracer-all-function branch December 12, 2025 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-next-release Required for the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants