summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/src/multiarray/common.h2
-rw-r--r--numpy/core/src/multiarray/nditer_constr.c9
-rw-r--r--numpy/core/src/multiarray/nditer_impl.h9
-rw-r--r--numpy/core/tests/test_ufunc.py2
4 files changed, 11 insertions, 11 deletions
diff --git a/numpy/core/src/multiarray/common.h b/numpy/core/src/multiarray/common.h
index eb6eef240..63377d07e 100644
--- a/numpy/core/src/multiarray/common.h
+++ b/numpy/core/src/multiarray/common.h
@@ -349,7 +349,7 @@ new_array_for_sum(PyArrayObject *ap1, PyArrayObject *ap2, PyArrayObject* out,
* probably. So we should consider making this public either as a macro or
* function (so that the way we flag the axis can be changed).
*/
-#define NPY_ITER_REDUCTION_AXIS(axis) (axis + (NPY_MAX_INT >> 1))
+#define NPY_ITER_REDUCTION_AXIS(axis) (axis + (1 << (NPY_BITSOF_INT - 2)))
#endif
diff --git a/numpy/core/src/multiarray/nditer_constr.c b/numpy/core/src/multiarray/nditer_constr.c
index c717f290f..91882fd9d 100644
--- a/numpy/core/src/multiarray/nditer_constr.c
+++ b/numpy/core/src/multiarray/nditer_constr.c
@@ -2600,10 +2600,8 @@ npyiter_new_temp_array(NpyIter *iter, PyTypeObject *subtype,
}
}
else {
+ assert(!reduction_axis || shape[i] == 1);
stride *= shape[i];
- if (reduction_axis) {
- assert(shape[i] == 1);
- }
}
}
else {
@@ -2651,8 +2649,9 @@ npyiter_new_temp_array(NpyIter *iter, PyTypeObject *subtype,
op_ndim = used_op_ndim;
shape = new_shape;
/*
- * If op_axes [0, 2] is specified, there will a place in the strides
- * array where the value is not set.
+ * If there's a gap in the array's dimensions, it's an error.
+ * For instance, if op_axes [0, 2] is specified, there will a place
+ * in the strides array where the value is not set.
*/
for (i = 0; i < op_ndim; i++) {
if (strides[i] == NPY_MAX_INTP) {
diff --git a/numpy/core/src/multiarray/nditer_impl.h b/numpy/core/src/multiarray/nditer_impl.h
index 82997e6fe..1477c8631 100644
--- a/numpy/core/src/multiarray/nditer_impl.h
+++ b/numpy/core/src/multiarray/nditer_impl.h
@@ -303,16 +303,17 @@ struct NpyIter_AD {
/* Internal helper functions shared between implementation files */
/**
- * Undo the axis permutation of the iterator. When the operand has less
+ * Undo the axis permutation of the iterator. When the operand has fewer
* dimensions then the iterator, this can return negative values for
* inserted (broadcast) dimensions.
*
* @param axis Axis for which to undo the iterator axis permutation.
* @param ndim If `op_axes` is being used, this is the iterator dimension,
* otherwise this is the operand dimension.
- * @param perm he iterator axis permutation NIT_PERM(iter)
- * @param axis_flipped Will be set to to true if this is a flipped axis and
- * otherwise false. Can be NULL.
+ * @param perm The iterator axis permutation NIT_PERM(iter)
+ * @param axis_flipped Will be set to true if this is a flipped axis
+ * (i.e. is iterated in reversed order) and otherwise false.
+ * Can be NULL if the information is not needed.
* @return The unpermuted axis. Without `op_axes` this is correct, with
* `op_axes` this indexes into `op_axes` (unpermuted iterator axis)
*/
diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py
index 1dbfa87e3..f7126f135 100644
--- a/numpy/core/tests/test_ufunc.py
+++ b/numpy/core/tests/test_ufunc.py
@@ -1922,7 +1922,7 @@ class TestUfunc:
assert_(check is out)
assert_array_equal(check, correct_out)
- def test_reduce_output_no_subclass(self):
+ def test_reduce_output_subclass_ok(self):
class MyArr(np.ndarray):
pass