Skip to content

fix: fix ak.validity_error for typetracer-backed layouts with unknown length#3784

Merged
ikrommyd merged 5 commits intoscikit-hep:mainfrom
ikrommyd:fix-typetracer-validity-check
Jan 8, 2026
Merged

fix: fix ak.validity_error for typetracer-backed layouts with unknown length#3784
ikrommyd merged 5 commits intoscikit-hep:mainfrom
ikrommyd:fix-typetracer-validity-check

Conversation

@ikrommyd
Copy link
Copy Markdown
Collaborator

@ikrommyd ikrommyd commented Jan 5, 2026

Fixes #3776

@ikrommyd
Copy link
Copy Markdown
Collaborator Author

ikrommyd commented Jan 5, 2026

I am still now sure whether we should do length checks for typetracer-backed layouts with known lengths or whether we should guard with nplike.known_data and not do any length checks at all if it's a typetracer-backed layout even when lengths are known.
I lean towards the former but I'm not sure if typetracer-backed layouts can have wrong lengths in certain cases making the check wrong.

@pfackeldey any takes here?

@ikrommyd
Copy link
Copy Markdown
Collaborator Author

ikrommyd commented Jan 5, 2026

Regarding testing, I just modified all the existing tests to test against unknown length typetracers too. I found it useless to just copy the exact same lines of code to a new test file and duplicate that many lines in tests.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 5, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.65%. Comparing base (03905ba) to head (7cbcab1).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/awkward/contents/recordarray.py 75.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/awkward/contents/bitmaskedarray.py 70.02% <100.00%> (ø)
src/awkward/contents/listoffsetarray.py 81.13% <100.00%> (ø)
src/awkward/contents/numpyarray.py 91.32% <100.00%> (ø)
src/awkward/contents/regulararray.py 86.99% <100.00%> (ø)
src/awkward/contents/recordarray.py 85.13% <75.00%> (+0.02%) ⬆️

... and 2 files with indirect coverage changes

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

@ikrommyd ikrommyd changed the title fix: fix ak.validity_check for typetracer-backed layouts with unknown length fix: fix ak.validity_error for typetracer-backed layouts with unknown length Jan 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 5, 2026

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

@ikrommyd ikrommyd marked this pull request as ready for review January 7, 2026 19:44
@ikrommyd ikrommyd requested a review from pfackeldey January 7, 2026 19:44
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, looks good to me! These guards were already there for some layouts if I understand that correctly, but just missing for others. The test cases are only enhanced, not reduced/altered, so that's good for me 👍

Copy link
Copy Markdown
Member

@ianna ianna left a comment

Choose a reason for hiding this comment

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

This PR fixes ak.validity_error incorrectly failing on typetracer-backed layouts with unknown length by guarding length-dependent checks behind known_data. The change is systematic across multiple content types and aligns validity semantics with typetracer expectations. Tests are extended to cover forget_length=True, preventing regressions. Overall: a correct, minimal, and well-tested fix for a real typetracer bug.

@ikrommyd
Copy link
Copy Markdown
Collaborator Author

ikrommyd commented Jan 8, 2026

Thanks, I will go ahead and merge it then.

Indeed @pfackeldey, it was there for some layouts but not for others. These are all the code paths I found by enabling testing.

@ikrommyd ikrommyd merged commit baa6059 into scikit-hep:main Jan 8, 2026
39 checks passed
@ikrommyd ikrommyd deleted the fix-typetracer-validity-check branch January 8, 2026 14:11
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.

Multiple typetracer-backed layouts raise errors related to unknown length on ak.validity_error checks

3 participants