Skip to content

Conversation

@vlad-perevezentsev
Copy link
Contributor

@vlad-perevezentsev vlad-perevezentsev commented Nov 4, 2025

This PR marks dpnp.asfarray() as deprecated to align with NumPy>=2.0 where this function was removed (Release Notes Numpy 2.0)

A DeprecationWarning is now raised informing users that the function will be removed in a future release and suggesting to use dpnp.asarray(dtype=...) instead.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

View rendered docs @ https://intelpython.github.io/dpnp/pull/2650/index.html

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

Array API standard conformance tests for dpnp=0.20.0dev0=py313h509198e_30 ran successfully.
Passed: 1227
Failed: 0
Skipped: 9

@coveralls
Copy link
Collaborator

coveralls commented Nov 4, 2025

Coverage Status

coverage: 81.51%. remained the same
when pulling 2699684 on remove_asfarray
into 5b39d66 on master.

@antonwolfy antonwolfy added this to the 0.20.0 release milestone Nov 4, 2025
@vlad-perevezentsev vlad-perevezentsev self-assigned this Nov 5, 2025
@vlad-perevezentsev vlad-perevezentsev changed the title Remove dpnp.asfarray() Deprecate dpnp.asfarray() and raise a DeprecationWarning Nov 5, 2025
array([2., 3.], dtype=float32)
>>> np.asfarray([2, 3], dtype=dpnp.int32)
array([2., 3.])
Copy link
Contributor

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.asarray and will be removed in a future release.

"""

warnings.warn(
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor

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,
Copy link
Contributor

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.])
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants