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

DEPR: Raise FutureWarning about raising an error in __array__ when copy=False cannot be honored #60395

Draft
wants to merge 6 commits into
base: 2.3.x
Choose a base branch
from

Conversation

KevsterAmp
Copy link
Contributor

@KevsterAmp KevsterAmp commented Nov 22, 2024

@KevsterAmp KevsterAmp changed the base branch from main to 2.3.x November 22, 2024 13:44
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks, looking good!

If you remove the error, you will have to update some tests that are now checking for an error (change that to check for a warning, with tm.assert_produces_warning)

And see the issue for a suggestion to expand the message.

Comment on lines 666 to 668
import warnings

from pandas.util._exceptions import find_stack_level
Copy link
Member

Choose a reason for hiding this comment

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

You can move those warnings to the top of the file

"raise an error when a zero-copy numpy array is not possible",
FutureWarning,
stacklevel=find_stack_level(),
)
# TODO: By using `zero_copy_only` it may be possible to implement this
raise ValueError(
Copy link
Member

Choose a reason for hiding this comment

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

This error should then be removed (we are adding the warning instead of the error, to warn people it will error in the future).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, I initially thought we would raise both an error and a warning.

Comment on lines 1675 to 1677
import warnings

from pandas.util._exceptions import find_stack_level
Copy link
Member

Choose a reason for hiding this comment

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

Same here about the imports (and similar for next cases)

"raise an error when a zero-copy numpy array is not possible",
FutureWarning,
stacklevel=find_stack_level(),
)
raise ValueError(
Copy link
Member

Choose a reason for hiding this comment

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

And same for the errors

@jorisvandenbossche jorisvandenbossche added this to the 2.3 milestone Nov 22, 2024
@jorisvandenbossche jorisvandenbossche added Compat pandas objects compatability with Numpy or Python functions Deprecate Functionality to remove in pandas labels Nov 23, 2024
@KevsterAmp
Copy link
Contributor Author

Thanks for the review despite this PR being in draft. Working on the tests and changes based on the comments, will mark it as ready once done

@KevsterAmp KevsterAmp marked this pull request as ready for review November 26, 2024 11:12
@KevsterAmp KevsterAmp marked this pull request as draft November 26, 2024 11:35
@KevsterAmp
Copy link
Contributor Author

Re-marking this as draft since I'll be fixing the errors on CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEPR: deprecate / warn about raising an error in __array__ when copy=False cannot be honore
2 participants