8000 MAINT: expire deprecations by mattip · Pull Request #28254 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: expire deprecations #28254

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 6 commits into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions benchmarks/benchmarks/bench_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def setup(self):
for i in range(self.fields_number)
]
)
self.buffer = self.l50.tostring() * self.fields_number
self.buffer = self.l50.tobytes() * self.fields_number

def time_fromarrays_w_dtype(self):
np._core.records.fromarrays(self.arrays, dtype=self.dtype_)
Expand All @@ -30,11 +30,11 @@ def time_fromarrays_formats_as_list(self):
def time_fromarrays_formats_as_string(self):
np._core.records.fromarrays(self.arrays, formats=self.formats_str)

def time_fromstring_w_dtype(self):
def time_frombytes_w_dtype(self):
np._core.records.fromstring(self.buffer, dtype=self.dtype_)

def time_fromstring_formats_as_list(self):
def time_frombytes_formats_as_list(self):
np._core.records.fromstring(self.buffer, formats=self.formats)

def time_fromstring_formats_as_string(self):
def time_frombytes_formats_as_string(self):
np._core.records.fromstring(self.buffer, formats=self.formats_str)
29 changes: 29 additions & 0 deletions doc/release/upcoming_changes/28254.expired.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
* Remove deprecated macros like ``NPY_OWNDATA`` from cython interfaces in favor of ``NPY_ARRAY_OWNDATA`` (deprecated since 1.7)
* Remove ``numpy/npy_1_7_deprecated_api.h`` and C macros like ``NPY_OWNDATA`` in favor of ``NPY_ARRAY_OWNDATA`` (deprecated since 1.7)
* Remove alias ``generate_divbyzero_error`` to ``npy_set_floatstatus_divbyzero`` and ``generate_overflow_error`` to ``npy_set_floatstatus_overflow`` (deprecated since 1.10)
* Remove ``np.tostring`` (deprecated since 1.19)
* Raise on ``np.conjugate`` of non-numeric types (deprecated since 1.13)
* Raise when using ``np.bincount(...minlength=None)``, use 0 intead (deprecated since 1.14)
* Passing ``shape=None`` to functions with a non-optional shape argument errors, use ``()`` instead (deprecated since 1.20)
* Inexact matches for ``mode`` and ``searchside`` raise (deprecated since 1.20)
* Setting ``__array_finalize__ = None`` errors (deprecated since 1.23)
* ``np.fromfile`` and ``np.fromstring`` error on bad data, previously they would guess (deprecated since 1.18)
* ``datetime64`` and ``timedelta64`` construction with a tuple no longer accepts an ``event`` value, either use a two-tuple of (unit, num) or a 4-tuple of (unit, num, den, 1) (deprecated since 1.14)
* When constructing a ``dtype`` from a class with a ``dtype`` attribute, that attribute must be a dtype-instance rather than a thing that can be parsed as a dtype instance (deprecated in 1.19). At some point the whole construct of using a dtype attribute will be deprecated (see #25306)
* Passing booleans as partition index errors (deprecated since 1.23)
* Out-of-bounds indexes error even on empty arrays (deprecated since 1.20)
* ``np.tostring`` has been removed, use ``tobytes`` instead (deprecated since 1.19)
* Disallow make a non-writeable array writeable for arrays with a base that do not own their data (deprecated since 1.17)
* ``concatenate()`` with ``axis=None`` uses ``same-kind`` casting by default, not ``unsafe`` (deprecated since 1.20)
* Unpickling a scalar with object dtype errors (deprecated since 1.20)
* The binary mode of ``fromstring`` now errors, use ``frombuffer`` instead (deprecated since 1.14)
* Converting ``np.inexact`` or ``np.floating`` to a dtype errors (deprecated since 1.19)
* Converting ``np.complex``, ``np.integer``, ``np.signedinteger``, ``np.unsignedinteger``, ``np.generic`` to a dtype errors (deprecated since 1.19)
* The Python built-in ``round`` errors for complex scalars. Use ``np.round`` or ``scalar.round`` instead (deprecated since 1.19)
* 'np.bool' scalars can no longer be interpreted as an index (deprecated since 1.19)
* Parsing an integer via a float string is no longer supported. (deprecated since 1.23) To avoid this error you can
* make sure the original data is stored as integers.
* use the ``converters=float`` keyword argument.
* Use ``np.loadtxt(...).astype(np.int64)``
* The use of a length 1 tuple for the ufunc ``signature`` errors. Use ``dtype`` or fill the tuple with ``None`` (deprecated since 1.19)
* Special handling of matrix is in np.outer is removed. Convert to a ndarray via ``matrix.A`` (deprecated since 1.20)
1 change: 0 additions & 1 deletion doc/source/reference/arrays.ndarray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ Array conversion

ndarray.item
ndarray.tolist
ndarray.tostring
ndarray.tobytes
ndarray.tofile
ndarray.dump
Expand Down
3 changes: 3 additions & 0 deletions doc/source/reference/c-api/ufunc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Constants
---------

``UFUNC_{THING}_{ERR}``

Deprecated, use ``NPY_{THING}_{ERR}`` instead

.. c:macro:: UFUNC_FPE_DIVIDEBYZERO

.. c:macro:: UFUNC_FPE_OVERFLOW
Expand Down
1 change: 0 additions & 1 deletion doc/source/reference/maskedarray.baseclass.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ Conversion
MaskedArray.toflex
MaskedArray.tolist
MaskedArray.torecords
MaskedArray.tostring
MaskedArray.tobytes


Expand Down
41 changes: 7 additions & 34 deletions numpy/__init__.cython-30.pxd
5D32
Original file line number Diff line number Diff line change
Expand Up @@ -192,40 +192,6 @@ cdef extern from "numpy/arrayobject.h":
NPY_SEARCHRIGHT

enum:
# DEPRECATED since NumPy 1.7 ! Do not use in new code!
NPY_C_CONTIGUOUS
NPY_F_CONTIGUOUS
NPY_CONTIGUOUS
NPY_FORTRAN
NPY_OWNDATA
NPY_FORCECAST
NPY_ENSURECOPY
NPY_ENSUREARRAY
NPY_ELEMENTSTRIDES
NPY_ALIGNED
NPY_NOTSWAPPED
NPY_WRITEABLE
NPY_ARR_HAS_DESCR

NPY_BEHAVED
NPY_BEHAVED_NS
NPY_CARRAY
NPY_CARRAY_RO
NPY_FARRAY
NPY_FARRAY_RO
NPY_DEFAULT

NPY_IN_ARRAY
NPY_OUT_ARRAY
NPY_INOUT_ARRAY
NPY_IN_FARRAY
NPY_OUT_FARRAY
NPY_INOUT_FARRAY

NPY_UPDATE_ALL

enum:
# Added in NumPy 1.7 to replace the deprecated enums above.
NPY_ARRAY_C_CONTIGUOUS
NPY_ARRAY_F_CONTIGUOUS
NPY_ARRAY_OWNDATA
Expand Down Expand Up @@ -964,10 +930,17 @@ cdef extern from "numpy/ufuncobject.h":
PyUFunc_Zero
PyUFunc_One
PyUFunc_None
# deprecated
UFUNC_FPE_DIVIDEBYZERO
UFUNC_FPE_OVERFLOW
UFUNC_FPE_UNDERFLOW
UFUNC_FPE_INVALID
# use these instead
NPY_FPE_DIVIDEBYZERO
NPY_FPE_OVERFLOW
NPY_FPE_UNDERFLOW
NPY_FPE_INVALID


object PyUFunc_FromFuncAndData(PyUFuncGenericFunction *,
void **, char *, int, int, int, int, char *, char *, int)
Expand Down
40 changes: 6 additions & 34 deletions numpy/__init__.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -201,40 +201,6 @@ cdef extern from "numpy/arrayobject.h":
NPY_SEARCHRIGHT

enum:
# DEPRECATED since NumPy 1.7 ! Do not use in new code!
NPY_C_CONTIGUOUS
NPY_F_CONTIGUOUS
NPY_CONTIGUOUS
NPY_FORTRAN
NPY_OWNDATA
NPY_FORCECAST
NPY_ENSURECOPY
NPY_ENSUREARRAY
NPY_ELEMENTSTRIDES
NPY_ALIGNED
NPY_NOTSWAPPED
NPY_WRITEABLE
NPY_ARR_HAS_DESCR

NPY_BEHAVED
NPY_BEHAVED_NS
NPY_CARRAY
NPY_CARRAY_RO
NPY_FARRAY
NPY_FARRAY_RO
NPY_DEFAULT

NPY_IN_ARRAY
NPY_OUT_ARRAY
NPY_INOUT_ARRAY
NPY_IN_FARRAY
NPY_OUT_FARRAY
NPY_INOUT_FARRAY

NPY_UPDATE_ALL

enum:
# Added in NumPy 1.7 to replace the deprecated enums above.
NPY_ARRAY_C_CONTIGUOUS
NPY_ARRAY_F_CONTIGUOUS
NPY_ARRAY_OWNDATA
Expand Down Expand Up @@ -879,10 +845,16 @@ cdef extern from "numpy/ufuncobject.h":
PyUFunc_Zero
PyUFunc_One
PyUFunc_None
# deprecated
UFUNC_FPE_DIVIDEBYZERO
UFUNC_FPE_OVERFLOW
UFUNC_FPE_UNDERFLOW
UFUNC_FPE_INVALID
# use these instead
NPY_FPE_DIVIDEBYZERO
NPY_FPE_OVERFLOW
NPY_FPE_UNDERFLOW
NPY_FPE_INVALID

object PyUFunc_FromFuncAndData(PyUFuncGenericFunction *,
void **, char *, int, int, int, int, char *, char *, int)
Expand Down
2 changes: 0 additions & 2 deletions numpy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1688,8 +1688,6 @@ class _ArrayOrScalarCommon:
def dump(self, file: StrOrBytesPath | SupportsWrite[bytes]) -> None: ...
def dumps(self) -> bytes: ...
def tobytes(self, order: _OrderKACF = ...) -> bytes: ...
# NOTE: `tostring()` is deprecated and therefore excluded
# def tostring(self, order=...): ...
def tofile(self, fid: StrOrBytesPath | _SupportsFileMethods, sep: str = ..., format: str = ...) -> None: ...
# generics and 0d arrays return builtin scalars
def tolist(self) -> Any: ...
Expand Down
12 changes: 0 additions & 12 deletions numpy/_core/_add_newdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4445,18 +4445,6 @@
"""))


add_newdoc('numpy._core.multiarray', 'ndarray', ('tostring', r"""
a.tostring(order='C')

A compatibility alias for `~ndarray.tobytes`, with exactly the same
behavior.

Despite its name, it returns :class:`bytes` not :class:`str`\ s.

.. deprecated:: 1.19.0
"""))


add_newdoc('numpy._core.multiarray', 'ndarray', ('trace',
"""
a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)
Expand Down
1 change: 0 additions & 1 deletion numpy/_core/include/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ installed_headers = [
'numpy/halffloat.h',
'numpy/ndarrayobject.h',
'numpy/ndarraytypes.h',
'numpy/npy_1_7_deprecated_api.h',
'numpy/npy_2_compat.h',
'numpy/npy_2_complexcompat.h',
'numpy/npy_3kcompat.h',
Expand Down
25 changes: 21 additions & 4 deletions numpy/_core/include/numpy/ndarraytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1908,10 +1908,6 @@ typedef struct {
#error "Do not use the reserved keyword NPY_DEPRECATED_INCLUDES."
#endif
#define NPY_DEPRECATED_INCLUDES
#if !defined(NPY_NO_DEPRECATED_API) || \
(NPY_NO_DEPRECATED_API < NPY_1_7_API_VERSION)
#include "npy_1_7_deprecated_api.h"
#endif
/*
* There is no file npy_1_8_deprecated_api.h since there are no additional
* deprecated API features in NumPy 1.8.
Expand All @@ -1923,6 +1919,27 @@ typedef struct {
* (NPY_NO_DEPRECATED_API < NPY_1_9_API_VERSION)
* #include "npy_1_9_deprecated_api.h"
* #endif
* Then in the npy_1_9_deprecated_api.h header add something like this
* --------------------
* #ifndef NPY_DEPRECATED_INCLUDES
* #error "Should never include npy_*_*_deprecated_api directly."
* #endif
* #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_1_7_DEPRECATED_API_H_
* #define NUMPY_CORE_INCLUDE_NUMPY_NPY_1_7_DEPRECATED_API_H_
*
* #ifndef NPY_NO_DEPRECATED_API
* #if defined(_WIN32)
* #define _WARN___STR2__(x) #x
* #define _WARN___STR1__(x) _WARN___STR2__(x)
* #define _WARN___LOC__ __FILE__ "(" _WARN___STR1__(__LINE__) ") : Warning Msg: "
* #pragma message(_WARN___LOC__"Using deprecated NumPy API, disable it with " \
* "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION")
* #else
* #warning "Using deprecated NumPy API, disable it with " \
* "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
* #endif
* #endif
* --------------------
*/
#undef NPY_DEPRECATED_INCLUDES

Expand Down
112 changes: 0 additions & 112 deletions numpy/_core/include/numpy/npy_1_7_deprecated_api.h

This file was deleted.

Loading
Loading
0