-
Notifications
You must be signed in to change notification settings - Fork 23
Deprecate dpnp.asfarray() and raise a DeprecationWarning
#2650
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
base: master
Are you sure you want to change the base?
Conversation
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/2650/index.html |
|
Array API standard conformance tests for dpnp=0.20.0dev0=py313h509198e_30 ran successfully. |
eea8f3c to
2699684
Compare
dpnp.asfarray()dpnp.asfarray() and raise a DeprecationWarning
| array([2., 3.], dtype=float32) | ||
| >>> np.asfarray([2, 3], dtype=dpnp.int32) | ||
| array([2., 3.]) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add a warning to the docstring that:
This function is deprecated in favor of :obj:
dpnp.asarrayand will be removed in a future release.
| """ | ||
|
|
||
| warnings.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be helpful to create a lingering doc page like CuPy has: docs/source/reference/_deprecated.rst. It would list all the active deprecations.
So the functions from that page will keep its docstring rendered, but not indexed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asfarray has to be removed from doc/reference/array-manipulation.rst, since deprecated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of that can be done in the follow up PR
| "and will be removed in a future release. " | ||
| "Please use `dpnp.asarray` with an appropriate dtype instead.", | ||
| DeprecationWarning, | ||
| stacklevel=2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dpnp/tests/test_arraymanipulation.py::TestAsfarray::test_asfarray_coverage is now raising a deprecation warning, please update the test to catch and check that.
| array([2., 3.], dtype=float32) | ||
| >>> np.asfarray([2, 3], dtype=dpnp.int32) | ||
| array([2., 3.]) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to remove links on :obj:dpnp.asfarray from the docstrings of other functions
This PR marks
dpnp.asfarray()as deprecated to align with NumPy>=2.0 where this function was removed (Release Notes Numpy 2.0)A
DeprecationWarningis now raised informing users that the function will be removed in a future release and suggesting to usedpnp.asarray(dtype=...)instead.