10000 API: bump MAXDIMS/MAXARGS to 64 introduce NPY_AXIS_RAVEL by seberg · Pull Request #25149 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

API: bump MAXDIMS/MAXARGS to 64 introduce NPY_AXIS_RAVEL #25149

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

Merged
merged 10 commits into from
Nov 28, 2023
Merged
Prev Previous commit
Address review comments
  • Loading branch information
seberg committed Nov 24, 2023
commit 0498d8cf18e1d061d17622fac680f901e5f15e36
6 changes: 3 additions & 3 deletions doc/release/upcoming_changes/25149.c_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Lager ``NPY_MAXDIMS`` and ``NPY_MAXARGS``, ``NPY_RAVEL_AXIS`` introduced
used in a stack allocation, where the increase should be safe.
However, we do encourage generally to remove any use of ``NPY_MAXDIMS`` and
``NPY_MAXARGS`` to eventually allow removing the constraint completely.
In some cases, ``NPY_MAXDIMS`` was passed (and returned) to mean ``axis=None``
these must be replaced with ``NPY_RAVEL_AXIS``.
See also :ref:`migration_maxdims`.
For the conversion helper and C-API functions mirrowing Python ones such as
``tale``, ``NPY_MAXDIMS`` was used to mean ``axis=None`` these must be
replaced with ``NPY_RAVEL_AXIS``. See also :ref:`migration_maxdims`.
2 changes: 2 additions & 0 deletions doc/release/upcoming_changes/25149.c_api_removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* ``NPY_MAX_ELSIZE`` macro has been removed as it only ever reflected
builtin numeric types and served no internal purpose.
10 changes: 6 additions & 4 deletions doc/source/numpy_2_0_migration_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ NumPy can remove this limitation on the number of dimensions.

``NPY_MAXDIMS`` was also used to signal ``axis=None`` in the C-API, including
the ``PyArray_AxisConverter``.
If you run into this problem, you will see ``-2147483648``
(the minimum integer value) or ``64`` being used as an invalid axis.
Wherever you do, you must replace ``NPY_MAXDIMS`` with ``NPY_RAVEL_AXIS``.
This is defined in the ``npy_2_compat.h`` header and runtime dependent.
The latter will return ``-2147483648`` as an axis (the smallest integer value).
Other functions may error with
``AxisError: axis 64 is out of bounds for array of dimension`` in which
case you need to pass ``NPY_RAVEL_AXIS`` instead of ``NPY_MAXDIMS``.
``NPY_RAVEL_AXIS`` is defined in the ``npy_2_compat.h`` header and runtime
dependent (mapping to 32 on NumPy 1.x and ``-2147483648`` on NumPy 2.x).


Namespace changes
Expand Down
4 changes: 3 additions & 1 deletion
Original file line number Diff line number Diff line change
Expand Up @@ -3456,7 +3456,9 @@ Other constants
have an ``axis`` argument. This macro may be passed for ``axis=None``.

.. note::
This macro is NumPy version dependent at runtime.
This macro is NumPy version dependent at runtime. The value is now
the minimum integer. However, on NumPy 1.x ``NPY_MAXDIMS`` was used
(at the time set to 32).


Miscellaneous Macros
Expand Down
9 changes: 5 additions & 4 deletions doc/source/reference/c-api/types-and-structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ PyArray_Type and PyArrayObject
array. Such arrays have undefined dimensions and strides and
cannot be accessed. Macro :c:data:`PyArray_NDIM` defined in
``ndarraytypes.h`` points to this data member.
Although most operations may be limited in dimensionality, we do not
advertise a maximum dimension. Anyone explicitly relying on one
must check for it. Before NumPy 2.0, NumPy used 32 dimensions at most
after it, the limit is currently 64.
``NPY_MAXDIMS`` is defined as a compile time constant limiting the
number of dimensions. This number is 64 since NumPy 2 and was 32
before. However, we may wish to remove this limitations in the future
so that it is best to explicitly check dimensionality for code
that relies on such an upper bound.

.. c:member:: npy_intp *dimensions

Expand Down
0