GH-49384: [Python] Respect copy=True in ChunkedArray.__array__#50541
Conversation
|
Thanks for opening a pull request! If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project. Then could you also rename the pull request title in the following format? or See also: |
|
|
|
@thisisnic this appears as merged but there's no commit and no changes, do you know what happened? Asking because it appears on GitHub UI as if merged by your user. I saw it before and was just chatting about it with @rok |
|
Yeah, this is super weird. I didn't merge this myself. I had Claude run an analysis which sounds bizarre but plausible - will paste its explanation below - let me know if this sounds feasible. The contributor ( Here's the timeline:
So the actual |
|
I agree this seems like a wrong rebase on main and no commit landed on main. The GitHub UI was just confusing showing it as merged and adding your user but the reasoning sounds plausible. Thanks for taking a look. @jingyi-zhao-01 feel free to submit a new PR, I've manually re-opened the issue. |
|
@raulcd got it i will open a feature branch on my forked repo |
|
Opened a new feature-branch PR here: #50561. This one contains the same scoped fix plus the regression test. |
Rationale for this change
ChunkedArray.__array__(copy=True)should respect NumPy's copy request. For a single-chunkChunkedArray, the current path can return a zero-copy read-only NumPy view instead.Closes #49384.
What changes are included in this PR?
ChunkedArray.__array__(copy=True)return a real NumPy copy.Are these changes tested?
Yes:
Are there any user-facing changes?
Yes.
np.array(pa.chunked_array([[...]]), copy=True)now returns a writable copied NumPy array, matching the behavior users expect fromcopy=True.AI assistance
I used an codex while preparing this patch. I reviewed the change myself, kept it scoped to
ChunkedArray.__array__, and verified it with the focused PyArrow table tests above.