Skip to content

fix: virtual array deep copy generator reference + better error message for assert_never#3644

Merged
ianna merged 4 commits intoscikit-hep:mainfrom
ikrommyd:ikrommyd/fix-deepcopy-generator-reference
Sep 10, 2025
Merged

fix: virtual array deep copy generator reference + better error message for assert_never#3644
ianna merged 4 commits intoscikit-hep:mainfrom
ikrommyd:ikrommyd/fix-deepcopy-generator-reference

Conversation

@ikrommyd
Copy link
Copy Markdown
Collaborator

@ikrommyd ikrommyd commented Sep 9, 2025

While deep copying virtual arrays, we used to do lambda: copy.deepcopy(self._generator(), memo) as the new generator.
The problem is that this apparently keeps a reference to self and not to self._generator. So when you make a copy and materialize the parent array first, its generator is set to assert_never in materialize, which effectively changes the generator of self. Therefore you cannot materialize the copy anymore because self._generator is now assert_never.
By extracting self._generator into a variable first, this keeps the right reference to the original generator and now you can materialize both the parent and the copied array in any order you want.

While we're at it, we add a better error message for assert_never, similar to the one for placeholder materialization.

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.65%. Comparing base (b749e49) to head (63ef333).
⚠️ Report is 419 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
src/awkward/_nplikes/virtual.py 90.54% <100.00%> (ø)

... and 196 files with indirect coverage changes

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

@lgray
Copy link
Copy Markdown
Collaborator

lgray commented Sep 9, 2025

After some discussion, this is high priority for coffea. If this can be approved and merged expediently, with a corresponding patch release, I would appreciate that with my coffea hat on. That, or I can take responsibility for it since I have merge rights on this repository.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 9, 2025

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

@ianna ianna changed the title fix: fix virtual array deep copy generator reference + better error message for assert_never fix: virtual array deep copy generator reference + better error message for assert_never Sep 9, 2025
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.

@ikrommyd - thanks for addressing the comments. Looks good to me. Thanks

@ikrommyd
Copy link
Copy Markdown
Collaborator Author

ikrommyd commented Sep 9, 2025

Anything we can do about the GPU ci that's apparently frozen?

@lgray
Copy link
Copy Markdown
Collaborator

lgray commented Sep 10, 2025

@ikrommyd it just takes a while to get a slot!

@ianna ianna merged commit 1d6d518 into scikit-hep:main Sep 10, 2025
131 of 134 checks passed
@ikrommyd ikrommyd deleted the ikrommyd/fix-deepcopy-generator-reference branch September 10, 2025 21:13
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.

3 participants