summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/source/reference/c-api/array.rst16
-rw-r--r--numpy/__init__.py7
-rw-r--r--numpy/core/_add_newdocs.py3
-rw-r--r--tools/swig/numpy.i122
4 files changed, 44 insertions, 104 deletions
diff --git a/doc/source/reference/c-api/array.rst b/doc/source/reference/c-api/array.rst
index bb22a1b03..8772b494c 100644
--- a/doc/source/reference/c-api/array.rst
+++ b/doc/source/reference/c-api/array.rst
@@ -3047,14 +3047,14 @@ to.
structure with base, ptr, len, and flags members. The
:c:type:`PyArray_Chunk` structure is binary compatible with the
Python's buffer object (through its len member on 32-bit platforms
- and its ptr member on 64-bit platforms or in Python 2.5). On
- return, the base member is set to *obj* (or its base if *obj* is
- already a buffer object pointing to another object). If you need
- to hold on to the memory be sure to INCREF the base member. The
- chunk of memory is pointed to by *buf* ->ptr member and has length
- *buf* ->len. The flags member of *buf* is :c:data:`NPY_ARRAY_ALIGNED`
- with the :c:data:`NPY_ARRAY_WRITEABLE` flag set if *obj* has
- a writeable buffer interface.
+ and its ptr member on 64-bit platforms). On return, the base member
+ is set to *obj* (or its base if *obj* is already a buffer object
+ pointing to another object). If you need to hold on to the memory
+ be sure to INCREF the base member. The chunk of memory is pointed
+ to by *buf* ->ptr member and has length *buf* ->len. The flags
+ member of *buf* is :c:data:`NPY_ARRAY_ALIGNED` with the
+ :c:data:`NPY_ARRAY_WRITEABLE` flag set if *obj* has a writeable
+ buffer interface.
.. c:function:: int PyArray_AxisConverter(PyObject* obj, int* axis)
diff --git a/numpy/__init__.py b/numpy/__init__.py
index 66b8e3eca..3260046d6 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -200,10 +200,9 @@ else:
_msg = (
"`np.{n}` is a deprecated alias for `np.compat.{n}`. "
- "To silence this warning, use `np.compat.{n}` by itself. "
- "In the likely event your code does not need to work on Python 2 "
- "you can use the builtin `{n2}` for which `np.compat.{n}` is itself "
- "an alias. Doing this will not modify any behaviour and is safe. "
+ "To silence this warning, use `np.compat.{n}` by itself, or "
+ "the builtin `{n2}` for which `np.compat.{n}` is itself an "
+ "alias. Doing this will not modify any behaviour and is safe. "
"{extended_msg}\n"
"Deprecated in NumPy 1.20; for more details and guidance: "
"https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations")
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
index 0405bfbe0..4ff838b77 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -1354,8 +1354,7 @@ add_newdoc('numpy.core.multiarray', 'fromstring',
decimal numbers, an operation which is better spelt
``frombuffer(string, dtype, count)``. If `string` contains unicode
text, the binary mode of `fromstring` will first encode it into
- bytes using either utf-8 (python 3) or the default encoding
- (python 2), neither of which produce sane results.
+ bytes using utf-8, which will not produce sane results.
${ARRAY_FUNCTION_LIKE}
diff --git a/tools/swig/numpy.i b/tools/swig/numpy.i
index 0ef92bab1..c8c26cbcd 100644
--- a/tools/swig/numpy.i
+++ b/tools/swig/numpy.i
@@ -48,7 +48,7 @@
%fragment("NumPy_Backward_Compatibility", "header")
{
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
%#define NPY_ARRAY_DEFAULT NPY_DEFAULT
%#define NPY_ARRAY_FARRAY NPY_FARRAY
%#define NPY_FORTRANORDER NPY_FORTRAN
@@ -69,7 +69,7 @@
{
/* Macros to extract array attributes.
*/
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
%#define is_array(a) ((a) && PyArray_Check((PyArrayObject*)a))
%#define array_type(a) (int)(PyArray_TYPE((PyArrayObject*)a))
%#define array_numdims(a) (((PyArrayObject*)a)->nd)
@@ -165,13 +165,11 @@
return PyArray_EquivTypenums(actual_type, desired_type);
}
-%#ifdef SWIGPY_USE_CAPSULE
- void free_cap(PyObject * cap)
+void free_cap(PyObject * cap)
{
void* array = (void*) PyCapsule_GetPointer(cap,SWIGPY_CAPSULE_NAME);
if (array != NULL) free(array);
}
-%#endif
}
@@ -293,7 +291,7 @@
Py_INCREF(array_descr(ary));
result = (PyArrayObject*) PyArray_FromArray(ary,
array_descr(ary),
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
NPY_FORTRANORDER);
%#else
NPY_ARRAY_F_CONTIGUOUS);
@@ -2459,13 +2457,9 @@
if (!array) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2493,13 +2487,9 @@
if (!array) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$2), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$2), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$2), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2528,13 +2518,9 @@
if (!array) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2563,13 +2549,9 @@
if (!array) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$3), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$3), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$3), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2598,13 +2580,9 @@
if (!array || !require_fortran(array)) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2633,13 +2611,9 @@
if (!array || !require_fortran(array)) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$3), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$3), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$3), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2670,13 +2644,9 @@
if (!array) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2707,13 +2677,9 @@
if (!array) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$4), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$4), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$4), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2744,13 +2710,9 @@
if (!array || !require_fortran(array)) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2781,13 +2743,9 @@
if (!array || !require_fortran(array)) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$4), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$4), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$4), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2819,13 +2777,9 @@
if (!array) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2857,13 +2811,9 @@
if (!array) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$5), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$5), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$5), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2895,13 +2845,9 @@
if (!array || !require_fortran(array)) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);
@@ -2933,13 +2879,9 @@
if (!array || !require_fortran(array)) SWIG_fail;
-%#ifdef SWIGPY_USE_CAPSULE
- PyObject* cap = PyCapsule_New((void*)(*$5), SWIGPY_CAPSULE_NAME, free_cap);
-%#else
- PyObject* cap = PyCObject_FromVoidPtr((void*)(*$5), free);
-%#endif
+PyObject* cap = PyCapsule_New((void*)(*$5), SWIGPY_CAPSULE_NAME, free_cap);
-%#if NPY_API_VERSION < 0x00000007
+%#if NPY_API_VERSION < NPY_1_7_API_VERSION
PyArray_BASE(array) = cap;
%#else
PyArray_SetBaseObject(array,cap);