summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/_pytesttester.py1
-rw-r--r--numpy/core/_add_newdocs.py57
-rw-r--r--numpy/core/multiarray.py2
-rw-r--r--numpy/core/numeric.py5
-rw-r--r--numpy/core/src/common/array_assign.c10
-rw-r--r--numpy/core/src/common/array_assign.h20
-rw-r--r--numpy/core/src/common/lowlevel_strided_loops.h36
-rw-r--r--numpy/core/src/multiarray/_multiarray_tests.c.src6
-rw-r--r--numpy/core/src/multiarray/array_assign_array.c18
-rw-r--r--numpy/core/src/multiarray/array_assign_scalar.c10
-rw-r--r--numpy/core/src/multiarray/arrayobject.c2
-rw-r--r--numpy/core/src/multiarray/common.c2
-rw-r--r--numpy/core/src/multiarray/common.h2
-rw-r--r--numpy/core/src/multiarray/compiled_base.c2
-rw-r--r--numpy/core/src/multiarray/conversion_utils.c2
-rw-r--r--numpy/core/src/multiarray/conversion_utils.h2
-rw-r--r--numpy/core/src/multiarray/ctors.c2
-rw-r--r--numpy/core/src/multiarray/dtype_transfer.c18
-rw-r--r--numpy/core/src/multiarray/einsum.c.src34
-rw-r--r--numpy/core/src/multiarray/item_selection.c6
-rw-r--r--numpy/core/src/multiarray/item_selection.h2
-rw-r--r--numpy/core/src/multiarray/lowlevel_strided_loops.c.src18
-rw-r--r--numpy/core/src/multiarray/methods.c2
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c46
-rw-r--r--numpy/core/src/multiarray/nditer_constr.c8
-rw-r--r--numpy/core/src/multiarray/shape.c2
-rw-r--r--numpy/core/src/multiarray/shape.h2
-rw-r--r--numpy/core/src/multiarray/strfuncs.c2
-rw-r--r--numpy/core/src/umath/reduction.h4
-rw-r--r--numpy/core/src/umath/ufunc_object.c10
-rw-r--r--numpy/core/tests/test_indexing.py20
-rw-r--r--numpy/core/tests/test_multiarray.py5
-rw-r--r--numpy/distutils/ccompiler.py9
-rw-r--r--numpy/distutils/command/config.py8
-rw-r--r--numpy/distutils/conv_template.py11
-rw-r--r--numpy/distutils/cpuinfo.py12
-rw-r--r--numpy/distutils/fcompiler/__init__.py12
-rw-r--r--numpy/distutils/fcompiler/compaq.py10
-rw-r--r--numpy/distutils/fcompiler/gnu.py5
-rw-r--r--numpy/distutils/misc_util.py6
-rw-r--r--numpy/distutils/system_info.py13
-rw-r--r--numpy/distutils/unixccompiler.py9
-rw-r--r--numpy/f2py/src/fortranobject.c2
-rw-r--r--numpy/testing/_private/nosetester.py3
44 files changed, 158 insertions, 300 deletions
diff --git a/numpy/_pytesttester.py b/numpy/_pytesttester.py
index cbe0779da..56eb3ac67 100644
--- a/numpy/_pytesttester.py
+++ b/numpy/_pytesttester.py
@@ -164,7 +164,6 @@ class PytestTester:
# Ignore python2.7 -3 warnings
pytest_args += [
- r"-W ignore:sys\.exc_clear\(\) not supported in 3\.x:DeprecationWarning",
r"-W ignore:in 3\.x, __setslice__:DeprecationWarning",
r"-W ignore:in 3\.x, __getslice__:DeprecationWarning",
r"-W ignore:buffer\(\) not supported in 3\.x:DeprecationWarning",
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
index 5c16827ed..f36c6941f 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -1034,7 +1034,7 @@ add_newdoc('numpy.core.multiarray', 'fromstring',
A string containing the data.
dtype : data-type, optional
The data type of the array; default: float. For binary input data,
- the data must be in exactly this format. Most builtin numeric types are
+ the data must be in exactly this format. Most builtin numeric types are
supported and extension types may be supported.
.. versionadded:: 1.18.0
@@ -1484,59 +1484,6 @@ add_newdoc('numpy.core.multiarray', 'promote_types',
""")
-if sys.version_info.major < 3:
- add_newdoc('numpy.core.multiarray', 'newbuffer',
- """
- newbuffer(size)
-
- Return a new uninitialized buffer object.
-
- Parameters
- ----------
- size : int
- Size in bytes of returned buffer object.
-
- Returns
- -------
- newbuffer : buffer object
- Returned, uninitialized buffer object of `size` bytes.
-
- """)
-
- add_newdoc('numpy.core.multiarray', 'getbuffer',
- """
- getbuffer(obj [,offset[, size]])
-
- Create a buffer object from the given object referencing a slice of
- length size starting at offset.
-
- Default is the entire buffer. A read-write buffer is attempted followed
- by a read-only buffer.
-
- Parameters
- ----------
- obj : object
-
- offset : int, optional
-
- size : int, optional
-
- Returns
- -------
- buffer_obj : buffer
-
- Examples
- --------
- >>> buf = np.getbuffer(np.ones(5), 1, 3)
- >>> len(buf)
- 3
- >>> buf[0]
- '\\x00'
- >>> buf
- <read-write buffer for 0x8af1e70, size 3, offset 1 at 0x8ba4ec0>
-
- """)
-
add_newdoc('numpy.core.multiarray', 'c_einsum',
"""
c_einsum(subscripts, *operands, out=None, dtype=None, order='K',
@@ -3951,7 +3898,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('tolist',
Examples
--------
- For a 1D array, ``a.tolist()`` is almost the same as ``list(a)``,
+ For a 1D array, ``a.tolist()`` is almost the same as ``list(a)``,
except that ``tolist`` changes numpy scalars to Python scalars:
>>> a = np.uint32([1, 2])
diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py
index 01fca1df5..5749afdcc 100644
--- a/numpy/core/multiarray.py
+++ b/numpy/core/multiarray.py
@@ -41,8 +41,6 @@ __all__ = [
'set_string_function', 'set_typeDict', 'shares_memory', 'test_interrupt',
'tracemalloc_domain', 'typeinfo', 'unpackbits', 'unravel_index', 'vdot',
'where', 'zeros']
-if sys.version_info.major < 3:
- __all__ += ['newbuffer', 'getbuffer']
# For backward compatibility, make sure pickle imports these functions from here
_reconstruct.__module__ = 'numpy.core.multiarray'
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index ae3dcd07a..505218a2e 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -19,8 +19,6 @@ from .multiarray import (
min_scalar_type, ndarray, nditer, nested_iters, promote_types,
putmask, result_type, set_numeric_ops, shares_memory, vdot, where,
zeros, normalize_axis_index)
-if sys.version_info[0] < 3:
- from .multiarray import newbuffer, getbuffer
from . import overrides
from . import umath
@@ -65,9 +63,6 @@ __all__ = [
'matmul', 'shares_memory', 'may_share_memory', 'MAY_SHARE_BOUNDS',
'MAY_SHARE_EXACT', 'TooHardError', 'AxisError']
-if sys.version_info[0] < 3:
- __all__.extend(['getbuffer', 'newbuffer'])
-
@set_module('numpy')
class ComplexWarning(RuntimeWarning):
diff --git a/numpy/core/src/common/array_assign.c b/numpy/core/src/common/array_assign.c
index 0ac1b01c6..d626d1260 100644
--- a/numpy/core/src/common/array_assign.c
+++ b/numpy/core/src/common/array_assign.c
@@ -27,9 +27,9 @@
/* See array_assign.h for parameter documentation */
NPY_NO_EXPORT int
-broadcast_strides(int ndim, npy_intp *shape,
- int strides_ndim, npy_intp *strides_shape, npy_intp *strides,
- char *strides_name,
+broadcast_strides(int ndim, npy_intp const *shape,
+ int strides_ndim, npy_intp const *strides_shape, npy_intp const *strides,
+ char const *strides_name,
npy_intp *out_strides)
{
int idim, idim_start = ndim - strides_ndim;
@@ -84,8 +84,8 @@ broadcast_error: {
/* See array_assign.h for parameter documentation */
NPY_NO_EXPORT int
-raw_array_is_aligned(int ndim, npy_intp *shape,
- char *data, npy_intp *strides, int alignment)
+raw_array_is_aligned(int ndim, npy_intp const *shape,
+ char *data, npy_intp const *strides, int alignment)
{
/*
diff --git a/numpy/core/src/common/array_assign.h b/numpy/core/src/common/array_assign.h
index 69ef56bb4..f5d884dd9 100644
--- a/numpy/core/src/common/array_assign.h
+++ b/numpy/core/src/common/array_assign.h
@@ -44,8 +44,8 @@ PyArray_AssignRawScalar(PyArrayObject *dst,
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-raw_array_assign_scalar(int ndim, npy_intp *shape,
- PyArray_Descr *dst_dtype, char *dst_data, npy_intp *dst_strides,
+raw_array_assign_scalar(int ndim, npy_intp const *shape,
+ PyArray_Descr *dst_dtype, char *dst_data, npy_intp const *dst_strides,
PyArray_Descr *src_dtype, char *src_data);
/*
@@ -55,11 +55,11 @@ raw_array_assign_scalar(int ndim, npy_intp *shape,
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-raw_array_wheremasked_assign_scalar(int ndim, npy_intp *shape,
- PyArray_Descr *dst_dtype, char *dst_data, npy_intp *dst_strides,
+raw_array_wheremasked_assign_scalar(int ndim, npy_intp const *shape,
+ PyArray_Descr *dst_dtype, char *dst_data, npy_intp const *dst_strides,
PyArray_Descr *src_dtype, char *src_data,
PyArray_Descr *wheremask_dtype, char *wheremask_data,
- npy_intp *wheremask_strides);
+ npy_intp const *wheremask_strides);
/******** LOW-LEVEL ARRAY MANIPULATION HELPERS ********/
@@ -80,9 +80,9 @@ raw_array_wheremasked_assign_scalar(int ndim, npy_intp *shape,
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-broadcast_strides(int ndim, npy_intp *shape,
- int strides_ndim, npy_intp *strides_shape, npy_intp *strides,
- char *strides_name,
+broadcast_strides(int ndim, npy_intp const *shape,
+ int strides_ndim, npy_intp const *strides_shape, npy_intp const *strides,
+ char const *strides_name,
npy_intp *out_strides);
/*
@@ -93,8 +93,8 @@ broadcast_strides(int ndim, npy_intp *shape,
* cannot-be-aligned, in which case 0 (false) is always returned.
*/
NPY_NO_EXPORT int
-raw_array_is_aligned(int ndim, npy_intp *shape,
- char *data, npy_intp *strides, int alignment);
+raw_array_is_aligned(int ndim, npy_intp const *shape,
+ char *data, npy_intp const *strides, int alignment);
/*
* Checks if an array is aligned to its "true alignment"
diff --git a/numpy/core/src/common/lowlevel_strided_loops.h b/numpy/core/src/common/lowlevel_strided_loops.h
index bacd27473..9208d5499 100644
--- a/numpy/core/src/common/lowlevel_strided_loops.h
+++ b/numpy/core/src/common/lowlevel_strided_loops.h
@@ -306,30 +306,30 @@ PyArray_CastRawArrays(npy_intp count,
NPY_NO_EXPORT npy_intp
PyArray_TransferNDimToStrided(npy_intp ndim,
char *dst, npy_intp dst_stride,
- char *src, npy_intp *src_strides, npy_intp src_strides_inc,
- npy_intp *coords, npy_intp coords_inc,
- npy_intp *shape, npy_intp shape_inc,
+ char *src, npy_intp const *src_strides, npy_intp src_strides_inc,
+ npy_intp const *coords, npy_intp coords_inc,
+ npy_intp const *shape, npy_intp shape_inc,
npy_intp count, npy_intp src_itemsize,
PyArray_StridedUnaryOp *stransfer,
NpyAuxData *transferdata);
NPY_NO_EXPORT npy_intp
PyArray_TransferStridedToNDim(npy_intp ndim,
- char *dst, npy_intp *dst_strides, npy_intp dst_strides_inc,
+ char *dst, npy_intp const *dst_strides, npy_intp dst_strides_inc,
char *src, npy_intp src_stride,
- npy_intp *coords, npy_intp coords_inc,
- npy_intp *shape, npy_intp shape_inc,
+ npy_intp const *coords, npy_intp coords_inc,
+ npy_intp const *shape, npy_intp shape_inc,
npy_intp count, npy_intp src_itemsize,
PyArray_StridedUnaryOp *stransfer,
NpyAuxData *transferdata);
NPY_NO_EXPORT npy_intp
PyArray_TransferMaskedStridedToNDim(npy_intp ndim,
- char *dst, npy_intp *dst_strides, npy_intp dst_strides_inc,
+ char *dst, npy_intp const *dst_strides, npy_intp dst_strides_inc,
char *src, npy_intp src_stride,
npy_bool *mask, npy_intp mask_stride,
- npy_intp *coords, npy_intp coords_inc,
- npy_intp *shape, npy_intp shape_inc,
+ npy_intp const *coords, npy_intp coords_inc,
+ npy_intp const *shape, npy_intp shape_inc,
npy_intp count, npy_intp src_itemsize,
PyArray_MaskedStridedUnaryOp *stransfer,
NpyAuxData *data);
@@ -365,8 +365,8 @@ mapiter_set(PyArrayMapIterObject *mit);
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-PyArray_PrepareOneRawArrayIter(int ndim, npy_intp *shape,
- char *data, npy_intp *strides,
+PyArray_PrepareOneRawArrayIter(int ndim, npy_intp const *shape,
+ char *data, npy_intp const *strides,
int *out_ndim, npy_intp *out_shape,
char **out_data, npy_intp *out_strides);
@@ -387,9 +387,9 @@ PyArray_PrepareOneRawArrayIter(int ndim, npy_intp *shape,
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-PyArray_PrepareTwoRawArrayIter(int ndim, npy_intp *shape,
- char *dataA, npy_intp *stridesA,
- char *dataB, npy_intp *stridesB,
+PyArray_PrepareTwoRawArrayIter(int ndim, npy_intp const *shape,
+ char *dataA, npy_intp const *stridesA,
+ char *dataB, npy_intp const *stridesB,
int *out_ndim, npy_intp *out_shape,
char **out_dataA, npy_intp *out_stridesA,
char **out_dataB, npy_intp *out_stridesB);
@@ -411,10 +411,10 @@ PyArray_PrepareTwoRawArrayIter(int ndim, npy_intp *shape,
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-PyArray_PrepareThreeRawArrayIter(int ndim, npy_intp *shape,
- char *dataA, npy_intp *stridesA,
- char *dataB, npy_intp *stridesB,
- char *dataC, npy_intp *stridesC,
+PyArray_PrepareThreeRawArrayIter(int ndim, npy_intp const *shape,
+ char *dataA, npy_intp const *stridesA,
+ char *dataB, npy_intp const *stridesB,
+ char *dataC, npy_intp const *stridesC,
int *out_ndim, npy_intp *out_shape,
char **out_dataA, npy_intp *out_stridesA,
char **out_dataB, npy_intp *out_stridesB,
diff --git a/numpy/core/src/multiarray/_multiarray_tests.c.src b/numpy/core/src/multiarray/_multiarray_tests.c.src
index 5e2cf0edd..1a51c06c7 100644
--- a/numpy/core/src/multiarray/_multiarray_tests.c.src
+++ b/numpy/core/src/multiarray/_multiarray_tests.c.src
@@ -55,7 +55,7 @@ EXPORT(void*) forward_pointer(void *x)
* #typenum = NPY_DOUBLE, NPY_INT#
*/
static int copy_@name@(PyArrayIterObject *itx, PyArrayNeighborhoodIterObject *niterx,
- npy_intp *bounds,
+ npy_intp const *bounds,
PyObject **out)
{
npy_intp i, j;
@@ -97,7 +97,7 @@ static int copy_@name@(PyArrayIterObject *itx, PyArrayNeighborhoodIterObject *ni
/**end repeat**/
static int copy_object(PyArrayIterObject *itx, PyArrayNeighborhoodIterObject *niterx,
- npy_intp *bounds,
+ npy_intp const *bounds,
PyObject **out)
{
npy_intp i, j;
@@ -251,7 +251,7 @@ clean_ax:
static int
copy_double_double(PyArrayNeighborhoodIterObject *itx,
PyArrayNeighborhoodIterObject *niterx,
- npy_intp *bounds,
+ npy_intp const *bounds,
PyObject **out)
{
npy_intp i, j;
diff --git a/numpy/core/src/multiarray/array_assign_array.c b/numpy/core/src/multiarray/array_assign_array.c
index 7ff33ebd7..e40b6c719 100644
--- a/numpy/core/src/multiarray/array_assign_array.c
+++ b/numpy/core/src/multiarray/array_assign_array.c
@@ -29,8 +29,8 @@
* elements, as required by the copy/casting code in lowlevel_strided_loops.c
*/
NPY_NO_EXPORT int
-copycast_isaligned(int ndim, npy_intp *shape,
- PyArray_Descr *dtype, char *data, npy_intp *strides)
+copycast_isaligned(int ndim, npy_intp const *shape,
+ PyArray_Descr *dtype, char *data, npy_intp const *strides)
{
int aligned;
int big_aln, small_aln;
@@ -72,9 +72,9 @@ copycast_isaligned(int ndim, npy_intp *shape,
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-raw_array_assign_array(int ndim, npy_intp *shape,
- PyArray_Descr *dst_dtype, char *dst_data, npy_intp *dst_strides,
- PyArray_Descr *src_dtype, char *src_data, npy_intp *src_strides)
+raw_array_assign_array(int ndim, npy_intp const *shape,
+ PyArray_Descr *dst_dtype, char *dst_data, npy_intp const *dst_strides,
+ PyArray_Descr *src_dtype, char *src_data, npy_intp const *src_strides)
{
int idim;
npy_intp shape_it[NPY_MAXDIMS];
@@ -152,11 +152,11 @@ raw_array_assign_array(int ndim, npy_intp *shape,
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-raw_array_wheremasked_assign_array(int ndim, npy_intp *shape,
- PyArray_Descr *dst_dtype, char *dst_data, npy_intp *dst_strides,
- PyArray_Descr *src_dtype, char *src_data, npy_intp *src_strides,
+raw_array_wheremasked_assign_array(int ndim, npy_intp const *shape,
+ PyArray_Descr *dst_dtype, char *dst_data, npy_intp const *dst_strides,
+ PyArray_Descr *src_dtype, char *src_data, npy_intp const *src_strides,
PyArray_Descr *wheremask_dtype, char *wheremask_data,
- npy_intp *wheremask_strides)
+ npy_intp const *wheremask_strides)
{
int idim;
npy_intp shape_it[NPY_MAXDIMS];
diff --git a/numpy/core/src/multiarray/array_assign_scalar.c b/numpy/core/src/multiarray/array_assign_scalar.c
index ecb5be47b..6bc9bcfee 100644
--- a/numpy/core/src/multiarray/array_assign_scalar.c
+++ b/numpy/core/src/multiarray/array_assign_scalar.c
@@ -30,8 +30,8 @@
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-raw_array_assign_scalar(int ndim, npy_intp *shape,
- PyArray_Descr *dst_dtype, char *dst_data, npy_intp *dst_strides,
+raw_array_assign_scalar(int ndim, npy_intp const *shape,
+ PyArray_Descr *dst_dtype, char *dst_data, npy_intp const *dst_strides,
PyArray_Descr *src_dtype, char *src_data)
{
int idim;
@@ -101,11 +101,11 @@ raw_array_assign_scalar(int ndim, npy_intp *shape,
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-raw_array_wheremasked_assign_scalar(int ndim, npy_intp *shape,
- PyArray_Descr *dst_dtype, char *dst_data, npy_intp *dst_strides,
+raw_array_wheremasked_assign_scalar(int ndim, npy_intp const *shape,
+ PyArray_Descr *dst_dtype, char *dst_data, npy_intp const *dst_strides,
PyArray_Descr *src_dtype, char *src_data,
PyArray_Descr *wheremask_dtype, char *wheremask_data,
- npy_intp *wheremask_strides)
+ npy_intp const *wheremask_strides)
{
int idim;
npy_intp shape_it[NPY_MAXDIMS], dst_strides_it[NPY_MAXDIMS];
diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c
index a5cebfbd8..6a500bd3f 100644
--- a/numpy/core/src/multiarray/arrayobject.c
+++ b/numpy/core/src/multiarray/arrayobject.c
@@ -1601,7 +1601,7 @@ PyArray_ElementStrides(PyObject *obj)
/*NUMPY_API*/
NPY_NO_EXPORT npy_bool
PyArray_CheckStrides(int elsize, int nd, npy_intp numbytes, npy_intp offset,
- npy_intp *dims, npy_intp *newstrides)
+ npy_intp const *dims, npy_intp const *newstrides)
{
npy_intp begin, end;
npy_intp lower_offset;
diff --git a/numpy/core/src/multiarray/common.c b/numpy/core/src/multiarray/common.c
index c991f7428..64113c40b 100644
--- a/numpy/core/src/multiarray/common.c
+++ b/numpy/core/src/multiarray/common.c
@@ -695,7 +695,7 @@ _IsWriteable(PyArrayObject *ap)
* @return Python unicode string
*/
NPY_NO_EXPORT PyObject *
-convert_shape_to_string(npy_intp n, npy_intp *vals, char *ending)
+convert_shape_to_string(npy_intp n, npy_intp const *vals, char *ending)
{
npy_intp i;
PyObject *ret, *tmp;
diff --git a/numpy/core/src/multiarray/common.h b/numpy/core/src/multiarray/common.h
index 7eee9ddc5..281fc437c 100644
--- a/numpy/core/src/multiarray/common.h
+++ b/numpy/core/src/multiarray/common.h
@@ -61,7 +61,7 @@ NPY_NO_EXPORT npy_bool
_IsWriteable(PyArrayObject *ap);
NPY_NO_EXPORT PyObject *
-convert_shape_to_string(npy_intp n, npy_intp *vals, char *ending);
+convert_shape_to_string(npy_intp n, npy_intp const *vals, char *ending);
/*
* Sets ValueError with "matrices not aligned" message for np.dot and friends
diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c
index cc37026b0..67c861549 100644
--- a/numpy/core/src/multiarray/compiled_base.c
+++ b/numpy/core/src/multiarray/compiled_base.c
@@ -1164,7 +1164,7 @@ fail:
* order must be NPY_CORDER or NPY_FORTRANORDER
*/
static int
-unravel_index_loop(int unravel_ndim, npy_intp *unravel_dims,
+unravel_index_loop(int unravel_ndim, npy_intp const *unravel_dims,
npy_intp unravel_size, npy_intp count,
char *indices, npy_intp indices_stride,
npy_intp *coords, NPY_ORDER order)
diff --git a/numpy/core/src/multiarray/conversion_utils.c b/numpy/core/src/multiarray/conversion_utils.c
index ca126b4b1..531d138d6 100644
--- a/numpy/core/src/multiarray/conversion_utils.c
+++ b/numpy/core/src/multiarray/conversion_utils.c
@@ -1145,7 +1145,7 @@ PyArray_TypestrConvert(int itemsize, int gentype)
PyArray_IntTupleFromIntp
*/
NPY_NO_EXPORT PyObject *
-PyArray_IntTupleFromIntp(int len, npy_intp *vals)
+PyArray_IntTupleFromIntp(int len, npy_intp const *vals)
{
int i;
PyObject *intTuple = PyTuple_New(len);
diff --git a/numpy/core/src/multiarray/conversion_utils.h b/numpy/core/src/multiarray/conversion_utils.h
index cd43f25c3..9bf712c3b 100644
--- a/numpy/core/src/multiarray/conversion_utils.h
+++ b/numpy/core/src/multiarray/conversion_utils.h
@@ -37,7 +37,7 @@ NPY_NO_EXPORT int
PyArray_TypestrConvert(int itemsize, int gentype);
NPY_NO_EXPORT PyObject *
-PyArray_IntTupleFromIntp(int len, npy_intp *vals);
+PyArray_IntTupleFromIntp(int len, npy_intp const *vals);
NPY_NO_EXPORT int
PyArray_SelectkindConverter(PyObject *obj, NPY_SELECTKIND *selectkind);
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c
index 6921427ce..599eb9765 100644
--- a/numpy/core/src/multiarray/ctors.c
+++ b/numpy/core/src/multiarray/ctors.c
@@ -950,7 +950,7 @@ discover_dimensions(PyObject *obj, int *maxndim, npy_intp *d, int check_it,
}
static PyObject *
-raise_memory_error(int nd, npy_intp *dims, PyArray_Descr *descr)
+raise_memory_error(int nd, npy_intp const *dims, PyArray_Descr *descr)
{
static PyObject *exc_type = NULL;
diff --git a/numpy/core/src/multiarray/dtype_transfer.c b/numpy/core/src/multiarray/dtype_transfer.c
index ef0dd4a01..b26d5ac89 100644
--- a/numpy/core/src/multiarray/dtype_transfer.c
+++ b/numpy/core/src/multiarray/dtype_transfer.c
@@ -3832,8 +3832,8 @@ PyArray_CastRawArrays(npy_intp count,
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-PyArray_PrepareOneRawArrayIter(int ndim, npy_intp *shape,
- char *data, npy_intp *strides,
+PyArray_PrepareOneRawArrayIter(int ndim, npy_intp const *shape,
+ char *data, npy_intp const *strides,
int *out_ndim, npy_intp *out_shape,
char **out_data, npy_intp *out_strides)
{
@@ -3953,9 +3953,9 @@ PyArray_PrepareOneRawArrayIter(int ndim, npy_intp *shape,
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-PyArray_PrepareTwoRawArrayIter(int ndim, npy_intp *shape,
- char *dataA, npy_intp *stridesA,
- char *dataB, npy_intp *stridesB,
+PyArray_PrepareTwoRawArrayIter(int ndim, npy_intp const *shape,
+ char *dataA, npy_intp const *stridesA,
+ char *dataB, npy_intp const *stridesB,
int *out_ndim, npy_intp *out_shape,
char **out_dataA, npy_intp *out_stridesA,
char **out_dataB, npy_intp *out_stridesB)
@@ -4077,10 +4077,10 @@ PyArray_PrepareTwoRawArrayIter(int ndim, npy_intp *shape,
* Returns 0 on success, -1 on failure.
*/
NPY_NO_EXPORT int
-PyArray_PrepareThreeRawArrayIter(int ndim, npy_intp *shape,
- char *dataA, npy_intp *stridesA,
- char *dataB, npy_intp *stridesB,
- char *dataC, npy_intp *stridesC,
+PyArray_PrepareThreeRawArrayIter(int ndim, npy_intp const *shape,
+ char *dataA, npy_intp const *stridesA,
+ char *dataB, npy_intp const *stridesB,
+ char *dataC, npy_intp const *stridesC,
int *out_ndim, npy_intp *out_shape,
char **out_dataA, npy_intp *out_stridesA,
char **out_dataB, npy_intp *out_stridesB,
diff --git a/numpy/core/src/multiarray/einsum.c.src b/numpy/core/src/multiarray/einsum.c.src
index 58af44091..70af3fef9 100644
--- a/numpy/core/src/multiarray/einsum.c.src
+++ b/numpy/core/src/multiarray/einsum.c.src
@@ -107,7 +107,7 @@
*/
static void
@name@_sum_of_products_@noplabel@(int nop, char **dataptr,
- npy_intp *strides, npy_intp count)
+ npy_intp const *strides, npy_intp count)
{
#if (@nop@ == 1) || (@nop@ <= 3 && !@complex@)
char *data0 = dataptr[0];
@@ -206,7 +206,7 @@ static void
static void
@name@_sum_of_products_contig_one(int nop, char **dataptr,
- npy_intp *NPY_UNUSED(strides), npy_intp count)
+ npy_intp const *NPY_UNUSED(strides), npy_intp count)
{
@type@ *data0 = (@type@ *)dataptr[0];
@type@ *data_out = (@type@ *)dataptr[1];
@@ -268,7 +268,7 @@ finish_after_unrolled_loop:
static void
@name@_sum_of_products_contig_two(int nop, char **dataptr,
- npy_intp *NPY_UNUSED(strides), npy_intp count)
+ npy_intp const *NPY_UNUSED(strides), npy_intp count)
{
@type@ *data0 = (@type@ *)dataptr[0];
@type@ *data1 = (@type@ *)dataptr[1];
@@ -354,7 +354,7 @@ finish_after_unrolled_loop:
/* Some extra specializations for the two operand case */
static void
@name@_sum_of_products_stride0_contig_outcontig_two(int nop, char **dataptr,
- npy_intp *NPY_UNUSED(strides), npy_intp count)
+ npy_intp const *NPY_UNUSED(strides), npy_intp count)
{
@temptype@ value0 = @from@(*(@type@ *)dataptr[0]);
@type@ *data1 = (@type@ *)dataptr[1];
@@ -483,7 +483,7 @@ finish_after_unrolled_loop:
static void
@name@_sum_of_products_contig_stride0_outcontig_two(int nop, char **dataptr,
- npy_intp *NPY_UNUSED(strides), npy_intp count)
+ npy_intp const *NPY_UNUSED(strides), npy_intp count)
{
@type@ *data0 = (@type@ *)dataptr[0];
@temptype@ value1 = @from@(*(@type@ *)dataptr[1]);
@@ -567,7 +567,7 @@ finish_after_unrolled_loop:
static void
@name@_sum_of_products_contig_contig_outstride0_two(int nop, char **dataptr,
- npy_intp *NPY_UNUSED(strides), npy_intp count)
+ npy_intp const *NPY_UNUSED(strides), npy_intp count)
{
@type@ *data0 = (@type@ *)dataptr[0];
@type@ *data1 = (@type@ *)dataptr[1];
@@ -727,7 +727,7 @@ finish_after_unrolled_loop:
static void
@name@_sum_of_products_stride0_contig_outstride0_two(int nop, char **dataptr,
- npy_intp *NPY_UNUSED(strides), npy_intp count)
+ npy_intp const *NPY_UNUSED(strides), npy_intp count)
{
@temptype@ value0 = @from@(*(@type@ *)dataptr[0]);
@type@ *data1 = (@type@ *)dataptr[1];
@@ -826,7 +826,7 @@ finish_after_unrolled_loop:
static void
@name@_sum_of_products_contig_stride0_outstride0_two(int nop, char **dataptr,
- npy_intp *NPY_UNUSED(strides), npy_intp count)
+ npy_intp const *NPY_UNUSED(strides), npy_intp count)
{
@type@ *data0 = (@type@ *)dataptr[0];
@temptype@ value1 = @from@(*(@type@ *)dataptr[1]);
@@ -927,7 +927,7 @@ finish_after_unrolled_loop:
static void
@name@_sum_of_products_contig_three(int nop, char **dataptr,
- npy_intp *NPY_UNUSED(strides), npy_intp count)
+ npy_intp const *NPY_UNUSED(strides), npy_intp count)
{
@type@ *data0 = (@type@ *)dataptr[0];
@type@ *data1 = (@type@ *)dataptr[1];
@@ -971,7 +971,7 @@ static void
static void
@name@_sum_of_products_contig_@noplabel@(int nop, char **dataptr,
- npy_intp *NPY_UNUSED(strides), npy_intp count)
+ npy_intp const *NPY_UNUSED(strides), npy_intp count)
{
NPY_EINSUM_DBG_PRINT1("@name@_sum_of_products_contig_@noplabel@ (%d)\n",
(int)count);
@@ -1024,7 +1024,7 @@ static void
static void
@name@_sum_of_products_contig_outstride0_one(int nop, char **dataptr,
- npy_intp *strides, npy_intp count)
+ npy_intp const *strides, npy_intp count)
{
#if @complex@
@temptype@ accum_re = 0, accum_im = 0;
@@ -1201,7 +1201,7 @@ finish_after_unrolled_loop:
static void
@name@_sum_of_products_outstride0_@noplabel@(int nop, char **dataptr,
- npy_intp *strides, npy_intp count)
+ npy_intp const *strides, npy_intp count)
{
#if @complex@
@temptype@ accum_re = 0, accum_im = 0;
@@ -1319,7 +1319,7 @@ static void
static void
bool_sum_of_products_@noplabel@(int nop, char **dataptr,
- npy_intp *strides, npy_intp count)
+ npy_intp const *strides, npy_intp count)
{
#if (@nop@ <= 3)
char *data0 = dataptr[0];
@@ -1376,7 +1376,7 @@ bool_sum_of_products_@noplabel@(int nop, char **dataptr,
static void
bool_sum_of_products_contig_@noplabel@(int nop, char **dataptr,
- npy_intp *strides, npy_intp count)
+ npy_intp const *strides, npy_intp count)
{
#if (@nop@ <= 3)
char *data0 = dataptr[0];
@@ -1484,7 +1484,7 @@ finish_after_unrolled_loop:
static void
bool_sum_of_products_outstride0_@noplabel@(int nop, char **dataptr,
- npy_intp *strides, npy_intp count)
+ npy_intp const *strides, npy_intp count)
{
npy_bool accum = 0;
@@ -1538,7 +1538,7 @@ bool_sum_of_products_outstride0_@noplabel@(int nop, char **dataptr,
/**end repeat**/
-typedef void (*sum_of_products_fn)(int, char **, npy_intp *, npy_intp);
+typedef void (*sum_of_products_fn)(int, char **, npy_intp const*, npy_intp);
/* These tables need to match up with the type enum */
static sum_of_products_fn
@@ -1720,7 +1720,7 @@ static sum_of_products_fn _unspecialized_table[NPY_NTYPES][4] = {
static sum_of_products_fn
get_sum_of_products_function(int nop, int type_num,
- npy_intp itemsize, npy_intp *fixed_strides)
+ npy_intp itemsize, npy_intp const *fixed_strides)
{
int iop;
diff --git a/numpy/core/src/multiarray/item_selection.c b/numpy/core/src/multiarray/item_selection.c
index e6867083f..e2c3ebd00 100644
--- a/numpy/core/src/multiarray/item_selection.c
+++ b/numpy/core/src/multiarray/item_selection.c
@@ -825,7 +825,7 @@ PyArray_Choose(PyArrayObject *ip, PyObject *op, PyArrayObject *out,
*/
static int
_new_sortlike(PyArrayObject *op, int axis, PyArray_SortFunc *sort,
- PyArray_PartitionFunc *part, npy_intp *kth, npy_intp nkth)
+ PyArray_PartitionFunc *part, npy_intp const *kth, npy_intp nkth)
{
npy_intp N = PyArray_DIM(op, axis);
npy_intp elsize = (npy_intp)PyArray_ITEMSIZE(op);
@@ -953,7 +953,7 @@ fail:
static PyObject*
_new_argsortlike(PyArrayObject *op, int axis, PyArray_ArgSortFunc *argsort,
PyArray_ArgPartitionFunc *argpart,
- npy_intp *kth, npy_intp nkth)
+ npy_intp const *kth, npy_intp nkth)
{
npy_intp N = PyArray_DIM(op, axis);
npy_intp elsize = (npy_intp)PyArray_ITEMSIZE(op);
@@ -2028,7 +2028,7 @@ count_nonzero_bytes_384(const npy_uint64 * w)
* Returns -1 on error.
*/
NPY_NO_EXPORT npy_intp
-count_boolean_trues(int ndim, char *data, npy_intp *ashape, npy_intp *astrides)
+count_boolean_trues(int ndim, char *data, npy_intp const *ashape, npy_intp const *astrides)
{
int idim;
npy_intp shape[NPY_MAXDIMS], strides[NPY_MAXDIMS];
diff --git a/numpy/core/src/multiarray/item_selection.h b/numpy/core/src/multiarray/item_selection.h
index 2276b4db7..c1c8b5567 100644
--- a/numpy/core/src/multiarray/item_selection.h
+++ b/numpy/core/src/multiarray/item_selection.h
@@ -8,7 +8,7 @@
* Returns -1 on error.
*/
NPY_NO_EXPORT npy_intp
-count_boolean_trues(int ndim, char *data, npy_intp *ashape, npy_intp *astrides);
+count_boolean_trues(int ndim, char *data, npy_intp const *ashape, npy_intp const *astrides);
/*
* Gets a single item from the array, based on a single multi-index
diff --git a/numpy/core/src/multiarray/lowlevel_strided_loops.c.src b/numpy/core/src/multiarray/lowlevel_strided_loops.c.src
index 63b2a8842..d234c366c 100644
--- a/numpy/core/src/multiarray/lowlevel_strided_loops.c.src
+++ b/numpy/core/src/multiarray/lowlevel_strided_loops.c.src
@@ -974,9 +974,9 @@ PyArray_GetStridedNumericCastFn(int aligned, npy_intp src_stride,
NPY_NO_EXPORT npy_intp
PyArray_TransferNDimToStrided(npy_intp ndim,
char *dst, npy_intp dst_stride,
- char *src, npy_intp *src_strides, npy_intp src_strides_inc,
- npy_intp *coords, npy_intp coords_inc,
- npy_intp *shape, npy_intp shape_inc,
+ char *src, npy_intp const *src_strides, npy_intp src_strides_inc,
+ npy_intp const *coords, npy_intp coords_inc,
+ npy_intp const *shape, npy_intp shape_inc,
npy_intp count, npy_intp src_itemsize,
PyArray_StridedUnaryOp *stransfer,
NpyAuxData *data)
@@ -1092,10 +1092,10 @@ PyArray_TransferNDimToStrided(npy_intp ndim,
/* See documentation of arguments in lowlevel_strided_loops.h */
NPY_NO_EXPORT npy_intp
PyArray_TransferStridedToNDim(npy_intp ndim,
- char *dst, npy_intp *dst_strides, npy_intp dst_strides_inc,
+ char *dst, npy_intp const *dst_strides, npy_intp dst_strides_inc,
char *src, npy_intp src_stride,
- npy_intp *coords, npy_intp coords_inc,
- npy_intp *shape, npy_intp shape_inc,
+ npy_intp const *coords, npy_intp coords_inc,
+ npy_intp const *shape, npy_intp shape_inc,
npy_intp count, npy_intp src_itemsize,
PyArray_StridedUnaryOp *stransfer,
NpyAuxData *data)
@@ -1211,11 +1211,11 @@ PyArray_TransferStridedToNDim(npy_intp ndim,
/* See documentation of arguments in lowlevel_strided_loops.h */
NPY_NO_EXPORT npy_intp
PyArray_TransferMaskedStridedToNDim(npy_intp ndim,
- char *dst, npy_intp *dst_strides, npy_intp dst_strides_inc,
+ char *dst, npy_intp const *dst_strides, npy_intp dst_strides_inc,
char *src, npy_intp src_stride,
npy_uint8 *mask, npy_intp mask_stride,
- npy_intp *coords, npy_intp coords_inc,
- npy_intp *shape, npy_intp shape_inc,
+ npy_intp const *coords, npy_intp coords_inc,
+ npy_intp const *shape, npy_intp shape_inc,
npy_intp count, npy_intp src_itemsize,
PyArray_MaskedStridedUnaryOp *stransfer,
NpyAuxData *data)
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c
index e5845f2f6..ae26bbd4a 100644
--- a/numpy/core/src/multiarray/methods.c
+++ b/numpy/core/src/multiarray/methods.c
@@ -1469,7 +1469,7 @@ array_argpartition(PyArrayObject *self, PyObject *args, PyObject *kwds)
static PyObject *
array_searchsorted(PyArrayObject *self, PyObject *args, PyObject *kwds)
{
- static char *kwlist[] = {"keys", "side", "sorter", NULL};
+ static char *kwlist[] = {"v", "side", "sorter", NULL};
PyObject *keys;
PyObject *sorter;
NPY_SEARCHSIDE side = NPY_SEARCHLEFT;
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index 58f64f0bb..a725d9a49 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -161,7 +161,7 @@ PyArray_MultiplyList(npy_intp const *l1, int n)
* Multiply a List of Non-negative numbers with over-flow detection.
*/
NPY_NO_EXPORT npy_intp
-PyArray_OverflowMultiplyList(npy_intp *l1, int n)
+PyArray_OverflowMultiplyList(npy_intp const *l1, int n)
{
npy_intp prod = 1;
int i;
@@ -3293,42 +3293,6 @@ array_datetime_data(PyObject *NPY_UNUSED(dummy), PyObject *args)
return convert_datetime_metadata_to_tuple(meta);
}
-#if !defined(NPY_PY3K)
-static PyObject *
-new_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args)
-{
- int size;
-
- if (!PyArg_ParseTuple(args, "i:buffer", &size)) {
- return NULL;
- }
- return PyBuffer_New(size);
-}
-
-static PyObject *
-buffer_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
-{
- PyObject *obj;
- Py_ssize_t offset = 0, n;
- Py_ssize_t size = Py_END_OF_BUFFER;
- void *unused;
- static char *kwlist[] = {"object", "offset", "size", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds,
- "O|" NPY_SSIZE_T_PYFMT NPY_SSIZE_T_PYFMT ":get_buffer", kwlist,
- &obj, &offset, &size)) {
- return NULL;
- }
- if (PyObject_AsWriteBuffer(obj, &unused, &n) < 0) {
- PyErr_Clear();
- return PyBuffer_FromObject(obj, offset, size);
- }
- else {
- return PyBuffer_FromReadWriteObject(obj, offset, size);
- }
-}
-#endif
-
/*
* Prints floating-point scalars using the Dragon4 algorithm, scientific mode.
* See docstring of `np.format_float_scientific` for description of arguments.
@@ -4137,14 +4101,6 @@ static struct PyMethodDef array_module_methods[] = {
{"is_busday",
(PyCFunction)array_is_busday,
METH_VARARGS | METH_KEYWORDS, NULL},
-#if !defined(NPY_PY3K)
- {"newbuffer",
- (PyCFunction)new_buffer,
- METH_VARARGS, NULL},
- {"getbuffer",
- (PyCFunction)buffer_buffer,
- METH_VARARGS | METH_KEYWORDS, NULL},
-#endif
{"format_longfloat",
(PyCFunction)format_longfloat,
METH_VARARGS | METH_KEYWORDS, NULL},
diff --git a/numpy/core/src/multiarray/nditer_constr.c b/numpy/core/src/multiarray/nditer_constr.c
index 5e770338d..e40a2d594 100644
--- a/numpy/core/src/multiarray/nditer_constr.c
+++ b/numpy/core/src/multiarray/nditer_constr.c
@@ -56,7 +56,7 @@ static int
npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, npyiter_opitflags *op_itflags,
char **op_dataptr,
const npy_uint32 *op_flags, int **op_axes,
- npy_intp *itershape);
+ npy_intp const *itershape);
static void
npyiter_replace_axisdata(NpyIter *iter, int iop,
PyArrayObject *op,
@@ -80,7 +80,7 @@ npyiter_get_common_dtype(int nop, PyArrayObject **op,
static PyArrayObject *
npyiter_new_temp_array(NpyIter *iter, PyTypeObject *subtype,
npy_uint32 flags, npyiter_opitflags *op_itflags,
- int op_ndim, npy_intp *shape,
+ int op_ndim, npy_intp const *shape,
PyArray_Descr *op_dtype, const int *op_axes);
static int
npyiter_allocate_arrays(NpyIter *iter,
@@ -1424,7 +1424,7 @@ static int
npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, npyiter_opitflags *op_itflags,
char **op_dataptr,
const npy_uint32 *op_flags, int **op_axes,
- npy_intp *itershape)
+ npy_intp const *itershape)
{
npy_uint32 itflags = NIT_ITFLAGS(iter);
int idim, ndim = NIT_NDIM(iter);
@@ -2476,7 +2476,7 @@ npyiter_get_common_dtype(int nop, PyArrayObject **op,
static PyArrayObject *
npyiter_new_temp_array(NpyIter *iter, PyTypeObject *subtype,
npy_uint32 flags, npyiter_opitflags *op_itflags,
- int op_ndim, npy_intp *shape,
+ int op_ndim, npy_intp const *shape,
PyArray_Descr *op_dtype, const int *op_axes)
{
npy_uint32 itflags = NIT_ITFLAGS(iter);
diff --git a/numpy/core/src/multiarray/shape.c b/numpy/core/src/multiarray/shape.c
index 4e31f003b..127ac5134 100644
--- a/numpy/core/src/multiarray/shape.c
+++ b/numpy/core/src/multiarray/shape.c
@@ -981,7 +981,7 @@ PyArray_Flatten(PyArrayObject *a, NPY_ORDER order)
/* See shape.h for parameters documentation */
NPY_NO_EXPORT PyObject *
-build_shape_string(npy_intp n, npy_intp *vals)
+build_shape_string(npy_intp n, npy_intp const *vals)
{
npy_intp i;
PyObject *ret, *tmp;
diff --git a/numpy/core/src/multiarray/shape.h b/numpy/core/src/multiarray/shape.h
index 0451a463e..d25292556 100644
--- a/numpy/core/src/multiarray/shape.h
+++ b/numpy/core/src/multiarray/shape.h
@@ -6,7 +6,7 @@
* A negative value in 'vals' gets interpreted as newaxis.
*/
NPY_NO_EXPORT PyObject *
-build_shape_string(npy_intp n, npy_intp *vals);
+build_shape_string(npy_intp n, npy_intp const *vals);
/*
* Creates a sorted stride perm matching the KEEPORDER behavior
diff --git a/numpy/core/src/multiarray/strfuncs.c b/numpy/core/src/multiarray/strfuncs.c
index 495d897b2..33f3a6543 100644
--- a/numpy/core/src/multiarray/strfuncs.c
+++ b/numpy/core/src/multiarray/strfuncs.c
@@ -64,7 +64,7 @@ extend_str(char **strp, Py_ssize_t n, Py_ssize_t *maxp)
static int
dump_data(char **string, Py_ssize_t *n, Py_ssize_t *max_n, char *data, int nd,
- npy_intp *dimensions, npy_intp *strides, PyArrayObject* self)
+ npy_intp const *dimensions, npy_intp const *strides, PyArrayObject* self)
{
PyObject *op = NULL, *sp = NULL;
char *ostring;
diff --git a/numpy/core/src/umath/reduction.h b/numpy/core/src/umath/reduction.h
index dfaeabcbb..0c2183ed6 100644
--- a/numpy/core/src/umath/reduction.h
+++ b/numpy/core/src/umath/reduction.h
@@ -100,8 +100,8 @@ typedef int (PyArray_AssignReduceIdentityFunc)(PyArrayObject *result,
*/
typedef int (PyArray_ReduceLoopFunc)(NpyIter *iter,
char **dataptr,
- npy_intp *strideptr,
- npy_intp *countptr,
+ npy_intp const *strideptr,
+ npy_intp const *countptr,
NpyIter_IterNextFunc *iternext,
int needs_api,
npy_intp skip_first_count,
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c
index 7bf530b6b..9ef0f822b 100644
--- a/numpy/core/src/umath/ufunc_object.c
+++ b/numpy/core/src/umath/ufunc_object.c
@@ -3424,8 +3424,8 @@ reduce_type_resolver(PyUFuncObject *ufunc, PyArrayObject *arr,
}
static int
-reduce_loop(NpyIter *iter, char **dataptrs, npy_intp *strides,
- npy_intp *countptr, NpyIter_IterNextFunc *iternext,
+reduce_loop(NpyIter *iter, char **dataptrs, npy_intp const *strides,
+ npy_intp const *countptr, NpyIter_IterNextFunc *iternext,
int needs_api, npy_intp skip_first_count, void *data)
{
PyArray_Descr *dtypes[3], **iter_dtypes;
@@ -3502,7 +3502,11 @@ reduce_loop(NpyIter *iter, char **dataptrs, npy_intp *strides,
strides_copy[2] = strides[0];
if (!masked) {
- innerloop(dataptrs_copy, countptr,
+ /* gh-15252: The signature of the inner loop considers `countptr`
+ * mutable. Inner loops aren't actually allowed to modify this
+ * though, so it's fine to cast it.
+ */
+ innerloop(dataptrs_copy, (npy_intp *)countptr,
strides_copy, innerloopdata);
}
else {
diff --git a/numpy/core/tests/test_indexing.py b/numpy/core/tests/test_indexing.py
index 635c84355..56bcf0177 100644
--- a/numpy/core/tests/test_indexing.py
+++ b/numpy/core/tests/test_indexing.py
@@ -9,7 +9,7 @@ from numpy.core._multiarray_tests import array_indexing
from itertools import product
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_array_equal, assert_warns,
- HAS_REFCOUNT, suppress_warnings,
+ HAS_REFCOUNT,
)
@@ -669,30 +669,16 @@ class TestSubclasses:
k[0:5]
assert_equal(k.indx, slice(0, 5))
assert_equal(sys.getrefcount(k.indx), 2)
- try:
+ with assert_raises(ValueError):
k[0:7]
- raise AssertionError
- except ValueError:
- # The exception holds a reference to the slice so clear on Py2
- if hasattr(sys, 'exc_clear'):
- with suppress_warnings() as sup:
- sup.filter(DeprecationWarning)
- sys.exc_clear()
assert_equal(k.indx, slice(0, 7))
assert_equal(sys.getrefcount(k.indx), 2)
k[0:3] = 6
assert_equal(k.indx, slice(0, 3))
assert_equal(sys.getrefcount(k.indx), 2)
- try:
+ with assert_raises(ValueError):
k[0:4] = 2
- raise AssertionError
- except ValueError:
- # The exception holds a reference to the slice so clear on Py2
- if hasattr(sys, 'exc_clear'):
- with suppress_warnings() as sup:
- sup.filter(DeprecationWarning)
- sys.exc_clear()
assert_equal(k.indx, slice(0, 4))
assert_equal(sys.getrefcount(k.indx), 2)
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 67d312652..bf1fcc76e 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -2161,6 +2161,8 @@ class TestMethods:
msg = "Test real searchsorted with nans, side='r'"
b = a.searchsorted(a, side='r')
assert_equal(b, np.arange(1, 4), msg)
+ # check keyword arguments
+ a.searchsorted(v=1)
# check double complex
a = np.zeros(9, dtype=np.complex128)
a.real += [0, 0, 1, 1, 0, 1, np.nan, np.nan, np.nan]
@@ -8240,9 +8242,6 @@ class TestArrayFinalize:
# get an array that crashed in __array_finalize__
with assert_raises(Exception) as e:
obj_arr.view(RaisesInFinalize)
- if sys.version_info.major == 2:
- # prevent an extra reference being kept
- sys.exc_clear()
obj_subarray = e.exception.args[0]
del e
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py
index 04d85e365..5e3cd0e74 100644
--- a/numpy/distutils/ccompiler.py
+++ b/numpy/distutils/ccompiler.py
@@ -14,7 +14,6 @@ from distutils.sysconfig import customize_compiler
from distutils.version import LooseVersion
from numpy.distutils import log
-from numpy.distutils.compat import get_exception
from numpy.distutils.exec_command import (
filepath_from_subprocess_output, forward_bytes_to_stdout
)
@@ -749,15 +748,15 @@ def new_compiler (plat=None,
module_name = "numpy.distutils." + module_name
try:
__import__ (module_name)
- except ImportError:
- msg = str(get_exception())
+ except ImportError as e:
+ msg = str(e)
log.info('%s in numpy.distutils; trying from distutils',
str(msg))
module_name = module_name[6:]
try:
__import__(module_name)
- except ImportError:
- msg = str(get_exception())
+ except ImportError as e:
+ msg = str(e)
raise DistutilsModuleError("can't compile C/C++ code: unable to load module '%s'" % \
module_name)
try:
diff --git a/numpy/distutils/command/config.py b/numpy/distutils/command/config.py
index 9a4665393..2c833aad7 100644
--- a/numpy/distutils/command/config.py
+++ b/numpy/distutils/command/config.py
@@ -22,7 +22,6 @@ from numpy.distutils.command.autodist import (check_gcc_function_attribute,
check_inline,
check_restrict,
check_compiler_gcc4)
-from numpy.distutils.compat import get_exception
LANG_EXT['f77'] = '.f'
LANG_EXT['f90'] = '.f90'
@@ -50,8 +49,7 @@ class config(old_config):
if not self.compiler.initialized:
try:
self.compiler.initialize()
- except IOError:
- e = get_exception()
+ except IOError as e:
msg = textwrap.dedent("""\
Could not initialize compiler instance: do you have Visual Studio
installed? If you are trying to build with MinGW, please use "python setup.py
@@ -94,8 +92,8 @@ class config(old_config):
self.compiler = self.fcompiler
try:
ret = mth(*((self,)+args))
- except (DistutilsExecError, CompileError):
- str(get_exception())
+ except (DistutilsExecError, CompileError) as e:
+ str(e)
self.compiler = save_compiler
raise CompileError
self.compiler = save_compiler
diff --git a/numpy/distutils/conv_template.py b/numpy/distutils/conv_template.py
index 8c84ddaae..ec5a84a68 100644
--- a/numpy/distutils/conv_template.py
+++ b/numpy/distutils/conv_template.py
@@ -85,8 +85,6 @@ import os
import sys
import re
-from numpy.distutils.compat import get_exception
-
# names for replacement that are already global.
global_names = {}
@@ -238,8 +236,7 @@ def parse_string(astr, env, level, line) :
code.append(replace_re.sub(replace, pref))
try :
envlist = parse_loop_header(head)
- except ValueError:
- e = get_exception()
+ except ValueError as e:
msg = "line %d: %s" % (newline, e)
raise ValueError(msg)
for newenv in envlist :
@@ -287,8 +284,7 @@ def process_file(source):
sourcefile = os.path.normcase(source).replace("\\", "\\\\")
try:
code = process_str(''.join(lines))
- except ValueError:
- e = get_exception()
+ except ValueError as e:
raise ValueError('In "%s" loop at %s' % (sourcefile, e))
return '#line 1 "%s"\n%s' % (sourcefile, code)
@@ -325,8 +321,7 @@ def main():
allstr = fid.read()
try:
writestr = process_str(allstr)
- except ValueError:
- e = get_exception()
+ except ValueError as e:
raise ValueError("In %s loop at %s" % (file, e))
outfile.write(writestr)
diff --git a/numpy/distutils/cpuinfo.py b/numpy/distutils/cpuinfo.py
index ebd257eea..efea90113 100644
--- a/numpy/distutils/cpuinfo.py
+++ b/numpy/distutils/cpuinfo.py
@@ -25,13 +25,10 @@ else:
import warnings
import platform
-from numpy.distutils.compat import get_exception
-
def getoutput(cmd, successful_status=(0,), stacklevel=1):
try:
status, output = getstatusoutput(cmd)
- except EnvironmentError:
- e = get_exception()
+ except EnvironmentError as e:
warnings.warn(str(e), UserWarning, stacklevel=stacklevel)
return False, ""
if os.WIFEXITED(status) and os.WEXITSTATUS(status) in successful_status:
@@ -113,8 +110,7 @@ class LinuxCPUInfo(CPUInfoBase):
info[0]['uname_m'] = output.strip()
try:
fo = open('/proc/cpuinfo')
- except EnvironmentError:
- e = get_exception()
+ except EnvironmentError as e:
warnings.warn(str(e), UserWarning, stacklevel=2)
else:
for line in fo:
@@ -521,8 +517,8 @@ class Win32CPUInfo(CPUInfoBase):
info[-1]["Family"]=int(srch.group("FML"))
info[-1]["Model"]=int(srch.group("MDL"))
info[-1]["Stepping"]=int(srch.group("STP"))
- except Exception:
- print(sys.exc_info()[1], '(ignoring)')
+ except Exception as e:
+ print(e, '(ignoring)')
self.__class__.info = info
def _not_impl(self): pass
diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py
index 6d99d3a61..a88b0d713 100644
--- a/numpy/distutils/fcompiler/__init__.py
+++ b/numpy/distutils/fcompiler/__init__.py
@@ -34,7 +34,6 @@ from numpy.distutils import log
from numpy.distutils.misc_util import is_string, all_strings, is_sequence, \
make_temp_file, get_shared_lib_extension
from numpy.distutils.exec_command import find_executable
-from numpy.distutils.compat import get_exception
from numpy.distutils import _shell_utils
from .environment import EnvironmentConfig
@@ -612,8 +611,8 @@ class FCompiler(CCompiler):
src)
try:
self.spawn(command, display=display)
- except DistutilsExecError:
- msg = str(get_exception())
+ except DistutilsExecError as e:
+ msg = str(e)
raise CompileError(msg)
def module_options(self, module_dirs, module_build_dir):
@@ -680,8 +679,8 @@ class FCompiler(CCompiler):
command = linker + ld_args
try:
self.spawn(command)
- except DistutilsExecError:
- msg = str(get_exception())
+ except DistutilsExecError as e:
+ msg = str(e)
raise LinkError(msg)
else:
log.debug("skipping %s (up-to-date)", output_filename)
@@ -929,8 +928,7 @@ def show_fcompilers(dist=None):
c = new_fcompiler(compiler=compiler, verbose=dist.verbose)
c.customize(dist)
v = c.get_version()
- except (DistutilsModuleError, CompilerNotFound):
- e = get_exception()
+ except (DistutilsModuleError, CompilerNotFound) as e:
log.debug("show_fcompilers: %s not found" % (compiler,))
log.debug(repr(e))
diff --git a/numpy/distutils/fcompiler/compaq.py b/numpy/distutils/fcompiler/compaq.py
index 2088f0c9b..6ce590c7c 100644
--- a/numpy/distutils/fcompiler/compaq.py
+++ b/numpy/distutils/fcompiler/compaq.py
@@ -4,7 +4,6 @@ import os
import sys
from numpy.distutils.fcompiler import FCompiler
-from numpy.distutils.compat import get_exception
from distutils.errors import DistutilsPlatformError
compilers = ['CompaqFCompiler']
@@ -80,19 +79,16 @@ class CompaqVisualFCompiler(FCompiler):
ar_exe = m.lib
except DistutilsPlatformError:
pass
- except AttributeError:
- msg = get_exception()
+ except AttributeError as e:
if '_MSVCCompiler__root' in str(msg):
print('Ignoring "%s" (I think it is msvccompiler.py bug)' % (msg))
else:
raise
- except IOError:
- e = get_exception()
+ except IOError as e:
if not "vcvarsall.bat" in str(e):
print("Unexpected IOError in", __file__)
raise e
- except ValueError:
- e = get_exception()
+ except ValueError as e:
if not "'path'" in str(e):
print("Unexpected ValueError in", __file__)
raise e
diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py
index 0a68fee72..4fc9f33ff 100644
--- a/numpy/distutils/fcompiler/gnu.py
+++ b/numpy/distutils/fcompiler/gnu.py
@@ -10,7 +10,6 @@ import subprocess
from subprocess import Popen, PIPE, STDOUT
from numpy.distutils.exec_command import filepath_from_subprocess_output
from numpy.distutils.fcompiler import FCompiler
-from numpy.distutils.compat import get_exception
from numpy.distutils.system_info import system_info
compilers = ['GnuFCompiler', 'Gnu95FCompiler']
@@ -558,5 +557,5 @@ if __name__ == '__main__':
print(customized_fcompiler('gnu').get_version())
try:
print(customized_fcompiler('g95').get_version())
- except Exception:
- print(get_exception())
+ except Exception as e:
+ print(e)
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py
index 8a24e6039..eec8d56a3 100644
--- a/numpy/distutils/misc_util.py
+++ b/numpy/distutils/misc_util.py
@@ -32,7 +32,6 @@ def clean_up_temporary_directory():
atexit.register(clean_up_temporary_directory)
-from numpy.distutils.compat import get_exception
from numpy.compat import basestring
from numpy.compat import npy_load_module
@@ -1970,9 +1969,8 @@ class Configuration:
try:
version_module = npy_load_module('_'.join(n.split('.')),
fn, info)
- except ImportError:
- msg = get_exception()
- self.warn(str(msg))
+ except ImportError as e:
+ self.warn(str(e))
version_module = None
if version_module is None:
continue
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
index 73f776dff..508aeefc5 100644
--- a/numpy/distutils/system_info.py
+++ b/numpy/distutils/system_info.py
@@ -161,7 +161,6 @@ from numpy.distutils.exec_command import (
from numpy.distutils.misc_util import (is_sequence, is_string,
get_shared_lib_extension)
from numpy.distutils.command.config import config as cmd_config
-from numpy.distutils.compat import get_exception
from numpy.distutils import customized_ccompiler as _customized_ccompiler
from numpy.distutils import _shell_utils
import distutils.ccompiler
@@ -2539,18 +2538,18 @@ class numerix_info(system_info):
try:
import numpy # noqa: F401
which = "numpy", "defaulted"
- except ImportError:
- msg1 = str(get_exception())
+ except ImportError as e:
+ msg1 = str(e)
try:
import Numeric # noqa: F401
which = "numeric", "defaulted"
- except ImportError:
- msg2 = str(get_exception())
+ except ImportError as e:
+ msg2 = str(e)
try:
import numarray # noqa: F401
which = "numarray", "defaulted"
- except ImportError:
- msg3 = str(get_exception())
+ except ImportError as e:
+ msg3 = str(e)
log.info(msg1)
log.info(msg2)
log.info(msg3)
diff --git a/numpy/distutils/unixccompiler.py b/numpy/distutils/unixccompiler.py
index 23db2a814..9a4d3ba52 100644
--- a/numpy/distutils/unixccompiler.py
+++ b/numpy/distutils/unixccompiler.py
@@ -7,7 +7,6 @@ import os
from distutils.errors import DistutilsExecError, CompileError
from distutils.unixccompiler import *
from numpy.distutils.ccompiler import replace_method
-from numpy.distutils.compat import get_exception
from numpy.distutils.misc_util import _commandline_dep_string
if sys.version_info[0] < 3:
@@ -54,8 +53,8 @@ def UnixCCompiler__compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts
try:
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + deps +
extra_postargs, display = display)
- except DistutilsExecError:
- msg = str(get_exception())
+ except DistutilsExecError as e:
+ msg = str(e)
raise CompileError(msg)
# add commandline flags to dependency file
@@ -126,8 +125,8 @@ def UnixCCompiler_create_static_lib(self, objects, output_libname,
try:
self.spawn(self.ranlib + [output_filename],
display = display)
- except DistutilsExecError:
- msg = str(get_exception())
+ except DistutilsExecError as e:
+ msg = str(e)
raise LibError(msg)
else:
log.debug("skipping %s (up-to-date)", output_filename)
diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c
index 973741ca7..456e64893 100644
--- a/numpy/f2py/src/fortranobject.c
+++ b/numpy/f2py/src/fortranobject.c
@@ -590,7 +590,7 @@ count_negative_dimensions(const int rank,
}
#ifdef DEBUG_COPY_ND_ARRAY
-void dump_dims(int rank, npy_intp* dims) {
+void dump_dims(int rank, npy_intp const* dims) {
int i;
printf("[");
for(i=0;i<rank;++i) {
diff --git a/numpy/testing/_private/nosetester.py b/numpy/testing/_private/nosetester.py
index a874321cc..73f5b3d35 100644
--- a/numpy/testing/_private/nosetester.py
+++ b/numpy/testing/_private/nosetester.py
@@ -454,9 +454,6 @@ class NoseTester:
# This is very specific, so using the fragile module filter
# is fine
import threading
- sup.filter(DeprecationWarning,
- r"sys\.exc_clear\(\) not supported in 3\.x",
- module=threading)
sup.filter(DeprecationWarning, message=r"in 3\.x, __setslice__")
sup.filter(DeprecationWarning, message=r"in 3\.x, __getslice__")
sup.filter(DeprecationWarning, message=r"buffer\(\) not supported in 3\.x")