Description
This tracking issue is meant to track the status and tasks of the Python API cleanup project for NumPy 2.0 (NEP 52, currently in draft status). Note: this is currently far from a complete plan, I wanted to make a start though at tracking things and making them actionable.
This issue is probably also a good place to suggest additional APIs to move/remove/deprecate, or other open issues that are related and can be tackled.
As a way of working, it'd be good to check usages of the function/object one is working on in downstream libraries (SciPy, scikit-learn, pandas is a good start), clean those up, then remove the object in question from the API. That has at least two benefits:
- it avoids CI in those projects to start failing when the change lands in a NumPy nightly,
- it gives a good sense of how easy it is to replace the usage with the recommended replacement
Cleaning up the main namespace
- Deal with all functions listed in Document, deprecate or remove everything exposed in the "numpy" namespace #12385
- Remove
np.inf
andnp.nan
aliases - Deprecate
np.compat
: API: deprecate compat and selected lib utils #23830 - See ENH: Overhaul of NumPy main namespace [NEP 52] #24306 for many more TODOs and decisions
Cleaning up the submodule structure
- Clean up
numpy.lib
: ENH: Overhaul of NumPylib
namespace [NEP 52] #24507
Reducing the number of ways to select dtypes
Actionable:
- Implement
np.isdtype
- Make adding new things to
sctypeDict
generate a deprecation warning. We cannot completely remove it because jax does this. See DEP: Deprecate registering dtype names with np.sctypeDict? #24699. - Deprecate (in 1.26.0) and remove (in 2.0)
sctype
related things (see ENH: add a canonical way to determine if dtype is integer, floating point or complex #17325 (comment)) - Remove
issubsctype
,sctypeDict
& co from SciPy, pandas (both have a few occurrences) and perhaps a few other large downstream libraries - Remove some of the more obscure aliases listed in https://numpy.org/devdocs/reference/arrays.scalars.html#other-aliases.
Cleaning up the niche methods on numpy.ndarray
There are the ones listed in the NEP right now
-
.setitem
-
.newbyteorder
-
.ptp
Doing the above ones will give a better idea about the amount of effort involved, and may help with then identifying a next set.
Documentation
- Update docs for the submodule structure (done in DOC: add a section on NumPy's module structure to the refguide #25674)
- Write a migration guide: https://numpy.org/devdocs/numpy_2_0_migration_guide.html
- Document how to use a tool or script for migrating to the 2.0 API: in progress with
ruff
by @mtsokol - Implement a
.. legacy::
Sphinx directive - in progress: DOC: Add legacy directive to mark outdated objects #24939 - Mark legacy APIs with
.. legacy::
directive
Metadata
Metadata
Type
Projects
Status