Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Accept keywords in ChunkedArray.to_numpy() for compatibility with Array.to_numpy() #34787

Closed
jorisvandenbossche opened this issue Mar 30, 2023 · 0 comments · Fixed by #35582

Comments

@jorisvandenbossche
Copy link
Member

Describe the enhancement requested

Currently, if you have "a" pyarrow array object that can be either array or chunked array, and you call to_numpy with something that cannot be zero copy, you need to do:

if isinstance(array, pyarrow.Array):
    np_arr = array.to_numpy(zero_copy_only=False)
else:
    np_arr = array.to_numpy()

instead of simply:

np_arr = array.to_numpy(zero_copy_only=False)

because the chunked array version doesn't accept the keyword. To make this easier, I think we should just accept that keyword in ChunkedArray.to_numpy() as well (and only accept False as a possible value)

Component(s)

Python

jjerphan added a commit to jjerphan/arrow that referenced this issue May 13, 2023
….to_numpy

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
jjerphan added a commit to jjerphan/arrow that referenced this issue May 13, 2023
….to_numpy

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
jjerphan added a commit to jjerphan/arrow that referenced this issue May 13, 2023
….to_numpy

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
jorisvandenbossche added a commit that referenced this issue Jul 10, 2023
…mpy (#35582)

### Rationale for this change

Addresses GH-34787.

### What changes are included in this PR?

I think this proposes the minimal viable changes to have the same signature as proposed in GH-34787.

### Are these changes tested?

Yes, for now, a single simple test has been introduced to test the correct behavior of `ChunkedArray.to_numpy` with respect to the addition of `zero_copy_only`.

* Closes: #34787

Lead-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
@jorisvandenbossche jorisvandenbossche added this to the 13.0.0 milestone Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant