summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/include/numpy/experimental_dtype_api.h24
-rw-r--r--numpy/core/src/multiarray/array_method.h21
-rw-r--r--numpy/core/src/umath/legacy_array_method.c2
3 files changed, 24 insertions, 23 deletions
diff --git a/numpy/core/include/numpy/experimental_dtype_api.h b/numpy/core/include/numpy/experimental_dtype_api.h
index 10015634d..a1418e929 100644
--- a/numpy/core/include/numpy/experimental_dtype_api.h
+++ b/numpy/core/include/numpy/experimental_dtype_api.h
@@ -307,10 +307,10 @@ typedef NPY_CASTING (resolve_descriptors_function)(
*
* NOTE: As of now, NumPy will NOT use unaligned loops in ufuncs!
*/
-#define NPY_METH_strided_loop 3
-#define NPY_METH_contiguous_loop 4
-#define NPY_METH_unaligned_strided_loop 5
-#define NPY_METH_unaligned_contiguous_loop 6
+#define NPY_METH_strided_loop 4
+#define NPY_METH_contiguous_loop 5
+#define NPY_METH_unaligned_strided_loop 6
+#define NPY_METH_unaligned_contiguous_loop 7
typedef struct {
@@ -331,12 +331,12 @@ typedef int (PyArrayMethod_StridedLoop)(PyArrayMethod_Context *context,
* Query an ArrayMethod for the initial value for use in reduction.
*
* @param context The arraymethod context, mainly to access the descriptors.
- * @param reduction_is_empty Whether the reduction is empty, when it is the
- * default value is required, otherwise an identity value to start the
- * the reduction. These might differ, examples:
- * - `0.0` as default for `sum([])`. But `-0.0` would be the correct
- * identity as it preserves the sign for `sum([-0.0])`.
- * - We use no identity for object, but `0` and `1` for sum and prod.
+ * @param reduction_is_empty Whether the reduction is empty. When it is, the
+ * default value for the identity might differ, for example:
+ * - `0.0` is the default for `sum([])`. But `-0.0` is the correct
+ * identity otherwise as it preserves the sign for `sum([-0.0])`.
+ * - We use no identity for object, but return the default of `0` and `1`
+ for the empty `sum([], dtype=object)` and `prod([], dtype=object)`.
* - `-inf` or `INT_MIN` for `max` is an identity, but at least `INT_MIN`
* not a good *default* when there are no items.
* @param initial Pointer to initial data to be filled (if possible)
@@ -345,8 +345,8 @@ typedef int (PyArrayMethod_StridedLoop)(PyArrayMethod_Context *context,
* successfully filled. Errors must not be given where 0 is correct, NumPy
* may call this even when not strictly necessary.
*/
- #define NPY_METH_get_reduction_initial 4
-typedef int (get_reduction_intial_function)(
+#define NPY_METH_get_reduction_initial 3
+typedef int (get_reduction_initial_function)(
PyArrayMethod_Context *context, npy_bool reduction_is_empty,
char *initial);
diff --git a/numpy/core/src/multiarray/array_method.h b/numpy/core/src/multiarray/array_method.h
index 0aca26d3b..694c342d3 100644
--- a/numpy/core/src/multiarray/array_method.h
+++ b/numpy/core/src/multiarray/array_method.h
@@ -108,12 +108,12 @@ typedef int (get_loop_function)(
* Query an ArrayMethod for the initial value for use in reduction.
*
* @param context The arraymethod context, mainly to access the descriptors.
- * @param reduction_is_empty Whether the reduction is empty, when it is the
- * default value is required, otherwise an identity value to start the
- * the reduction. These might differ, examples:
- * - `0.0` as default for `sum([])`. But `-0.0` would be the correct
- * identity as it preserves the sign for `sum([-0.0])`.
- * - We use no identity for object, but `0` and `1` for sum and prod.
+ * @param reduction_is_empty Whether the reduction is empty. When it is, the
+ * default value for the identity might differ, for example:
+ * - `0.0` is the default for `sum([])`. But `-0.0` is the correct
+ * identity otherwise as it preserves the sign for `sum([-0.0])`.
+ * - We use no identity for object, but return the default of `0` and `1`
+ for the empty `sum([], dtype=object)` and `prod([], dtype=object)`.
* - `-inf` or `INT_MIN` for `max` is an identity, but at least `INT_MIN`
* not a good *default* when there are no items.
* @param initial Pointer to initial data to be filled (if possible)
@@ -122,7 +122,7 @@ typedef int (get_loop_function)(
* successfully filled. Errors must not be given where 0 is correct, NumPy
* may call this even when not strictly necessary.
*/
-typedef int (get_reduction_intial_function)(
+typedef int (get_reduction_initial_function)(
PyArrayMethod_Context *context, npy_bool reduction_is_empty,
char *initial);
@@ -215,7 +215,7 @@ typedef struct PyArrayMethodObject_tag {
NPY_ARRAYMETHOD_FLAGS flags;
resolve_descriptors_function *resolve_descriptors;
get_loop_function *get_strided_loop;
- get_reduction_intial_function *get_reduction_initial;
+ get_reduction_initial_function *get_reduction_initial;
/* Typical loop functions (contiguous ones are used in current casts) */
PyArrayMethod_StridedLoop *strided_loop;
PyArrayMethod_StridedLoop *contiguous_loop;
@@ -258,8 +258,9 @@ extern NPY_NO_EXPORT PyTypeObject PyBoundArrayMethod_Type;
*/
#define NPY_METH_resolve_descriptors 1
#define NPY_METH_get_loop 2
-#define NPY_METH_strided_loop 3
-#define NPY_METH_get_reduction_initial 4
+#define NPY_METH_get_reduction_initial 3
+/* specific loops for constructions/default get_loop: */
+#define NPY_METH_strided_loop 4
#define NPY_METH_contiguous_loop 5
#define NPY_METH_unaligned_strided_loop 6
#define NPY_METH_unaligned_contiguous_loop 7
diff --git a/numpy/core/src/umath/legacy_array_method.c b/numpy/core/src/umath/legacy_array_method.c
index f507a0806..c0ac18b03 100644
--- a/numpy/core/src/umath/legacy_array_method.c
+++ b/numpy/core/src/umath/legacy_array_method.c
@@ -363,7 +363,7 @@ PyArray_NewLegacyWrappingArrayMethod(PyUFuncObject *ufunc,
flags = _NPY_METH_FORCE_CAST_INPUTS;
}
- get_reduction_intial_function *get_reduction_intial = NULL;
+ get_reduction_initial_function *get_reduction_intial = NULL;
if (ufunc->nin == 2 && ufunc->nout == 1) {
npy_bool reorderable = NPY_FALSE;
PyObject *identity_obj = PyUFunc_GetDefaultIdentity(