diff options
| -rw-r--r-- | numpy/core/src/umath/reduction.c | 2 | ||||
| -rw-r--r-- | numpy/core/tests/test_ufunc.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/numpy/core/src/umath/reduction.c b/numpy/core/src/umath/reduction.c index 8c4df6e02..817f99a04 100644 --- a/numpy/core/src/umath/reduction.c +++ b/numpy/core/src/umath/reduction.c @@ -68,7 +68,7 @@ count_axes(int ndim, const npy_bool *axis_flags) * Returns -1 if an error occurred, and otherwise the reduce arrays size, * which is the number of elements already initialized. */ -NPY_NO_EXPORT int +static npy_intp PyArray_CopyInitialReduceValues( PyArrayObject *result, PyArrayObject *operand, const npy_bool *axis_flags, const char *funcname, diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py index 9a9d46da0..41f9778b6 100644 --- a/numpy/core/tests/test_ufunc.py +++ b/numpy/core/tests/test_ufunc.py @@ -14,6 +14,7 @@ from numpy.testing import ( assert_almost_equal, assert_array_almost_equal, assert_no_warnings, assert_allclose, HAS_REFCOUNT, suppress_warnings ) +from numpy.testing._private.utils import requires_memory from numpy.compat import pickle @@ -1555,6 +1556,17 @@ class TestUfunc: [[0, 1, 1], [1, 1, 1]]) assert_equal(np.minimum.reduce(a, axis=()), a) + @requires_memory(6 * 1024**3) + def test_identityless_reduction_huge_array(self): + # Regression test for gh-20921 (copying identity incorrectly failed) + arr = np.zeros((2, 2**31), 'uint8') + arr[:, 0] = [1, 3] + arr[:, -1] = [4, 1] + res = np.maximum.reduce(arr, axis=0) + del arr + assert res[0] == 3 + assert res[-1] == 4 + def test_identityless_reduction_corder(self): a = np.empty((2, 3, 4), order='C') self.check_identityless_reduction(a) |
