[inequality] Take writeable copy before rd.shuffle (pandas 3.0 read-only fix)#776
Merged
Conversation
pandas 3.0 returns a read-only array from np.asarray() of a Series (Copy-on-Write), so rd.shuffle(y) raised "ValueError: assignment destination is read-only" during the anaconda=2026.06 build. Take a writeable .copy() before the in-place shuffle. See #775. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Deploy Preview for taupe-gaufre-c4e660 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
1 similar comment
✅ Deploy Preview for taupe-gaufre-c4e660 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Fixes execution of the inequality lecture under the anaconda=2026.06 stack (pandas 3.0 Copy-on-Write), where np.asarray() on a Series can yield a read-only NumPy array and cause random.shuffle to raise ValueError: assignment destination is read-only.
Changes:
- Make the array backing the Lorenz-curve shuffle explicitly writeable by taking a
.copy()afternp.asarray(...). - Add an inline note explaining the pandas 3.0 read-only behavior and why the copy is needed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Under the
anaconda=2026.06stack (pandas 3.0),np.asarray()of a Series returns a read-only array (Copy-on-Write), so the in-placerd.shuffle(y)in the Lorenz-curve loop raisedValueError: assignment destination is read-onlyand aborted execution ofinequality.md. This takes a writeable.copy()before the shuffle.This clears one of the two
anaconda=2026.06build failures tracked in #775. The other two notebooks (input_output,networks) are blocked by an upstreamquantecon_book_networksissue (QuantEcon/quantecon-book-networks#21), so the cache build won't be fully green until that lands (orsetuptoolsis added as a stopgap).Found during the cross-repo anaconda 2026.06 validation sweep.
🤖 Generated with Claude Code