summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorMark Wiebe <mwwiebe@gmail.com>2011-08-25 21:47:27 -0700
committerCharles Harris <charlesr.harris@gmail.com>2011-08-27 07:27:01 -0600
commitcc326304a60c35d38dc29adf2544a29d6dcedfee (patch)
tree2dfe5b1d41bff282e76286558651b9f784ec3528 /numpy
parenta43d255dbc243ea7910e1b92ba83704e1a880c70 (diff)
downloadnumpy-cc326304a60c35d38dc29adf2544a29d6dcedfee.tar.gz
ENH: missingdata: Make numpy.all follow the NA && False == False rule
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/_methods.py8
-rw-r--r--numpy/core/fromnumeric.py29
-rw-r--r--numpy/core/numeric.py4
-rw-r--r--numpy/core/src/multiarray/boolean_ops.c.src127
-rw-r--r--numpy/core/src/multiarray/boolean_ops.h4
-rw-r--r--numpy/core/src/multiarray/conversion_utils.c18
-rw-r--r--numpy/core/src/multiarray/methods.c36
-rw-r--r--numpy/core/tests/test_ufunc.py37
-rw-r--r--numpy/lib/tests/test_recfunctions.py4
9 files changed, 172 insertions, 95 deletions
diff --git a/numpy/core/_methods.py b/numpy/core/_methods.py
index 33de34e1a..747f4268c 100644
--- a/numpy/core/_methods.py
+++ b/numpy/core/_methods.py
@@ -21,14 +21,6 @@ def _prod(a, axis=None, dtype=None, out=None, skipna=False, keepdims=False):
return um.multiply.reduce(a, axis=axis, dtype=dtype,
out=out, skipna=skipna, keepdims=keepdims)
-def _any(a, axis=None, out=None, skipna=False, keepdims=False):
- return um.logical_or.reduce(a, axis=axis,
- out=out, skipna=skipna, keepdims=keepdims)
-
-def _all(a, axis=None, out=None, skipna=False, keepdims=False):
- return um.logical_and.reduce(a, axis=axis,
- out=out, skipna=skipna, keepdims=keepdims)
-
def _mean(a, axis=None, dtype=None, out=None, skipna=False, keepdims=False):
arr = asanyarray(a)
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index f374951c9..8e7a556ac 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -1514,8 +1514,12 @@ def sometrue(a, axis=None, out=None, skipna=False, keepdims=False):
any : equivalent function
"""
- return um.logical_or.reduce(a, axis=axis, out=out, skipna=skipna, keepdims=keepdims)
+ arr = asanyarray(a)
+ try:
+ return arr.any(axis=axis, out=out, skipna=skipna, keepdims=keepdims)
+ except TypeError:
+ return arr.any(axis=axis, out=out)
def alltrue (a, axis=None, out=None, skipna=False, keepdims=False):
"""
@@ -1526,7 +1530,12 @@ def alltrue (a, axis=None, out=None, skipna=False, keepdims=False):
numpy.all : Equivalent function; see for details.
"""
- return um.logical_and.reduce(a, axis=axis, out=out, skipna=skipna, keepdims=keepdims)
+ arr = asanyarray(a)
+
+ try:
+ return arr.all(axis=axis, out=out, skipna=skipna, keepdims=keepdims)
+ except TypeError:
+ return arr.all(axis=axis, out=out)
def any(a, axis=None, out=None, skipna=False, keepdims=False):
"""
@@ -1604,8 +1613,12 @@ def any(a, axis=None, out=None, skipna=False, keepdims=False):
(191614240, 191614240)
"""
- return _methods._any(a, axis=axis, out=out,
- skipna=skipna, keepdims=keepdims)
+ arr = asanyarray(a)
+
+ try:
+ return arr.any(axis=axis, out=out, skipna=skipna, keepdims=keepdims)
+ except TypeError:
+ return arr.any(axis=axis, out=out)
def all(a, axis=None, out=None, skipna=False, keepdims=False):
"""
@@ -1676,8 +1689,12 @@ def all(a, axis=None, out=None, skipna=False, keepdims=False):
(28293632, 28293632, array([ True], dtype=bool))
"""
- return _methods._all(a, axis=axis, out=out,
- skipna=skipna, keepdims=keepdims)
+ arr = asanyarray(a)
+
+ try:
+ return arr.all(axis=axis, out=out, skipna=skipna, keepdims=keepdims)
+ except TypeError:
+ return arr.all(axis=axis, out=out)
def cumsum (a, axis=None, dtype=None, out=None):
"""
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index a66a9764d..ba8fc1f52 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -2063,7 +2063,7 @@ def array_equal(a1, a2):
return False
if a1.shape != a2.shape:
return False
- return bool(logical_and.reduce(equal(a1,a2).ravel()))
+ return bool(equal(a1,a2).all())
def array_equiv(a1, a2):
"""
@@ -2105,7 +2105,7 @@ def array_equiv(a1, a2):
except:
return False
try:
- return bool(logical_and.reduce(equal(a1,a2).ravel()))
+ return bool(equal(a1,a2).all())
except ValueError:
return False
diff --git a/numpy/core/src/multiarray/boolean_ops.c.src b/numpy/core/src/multiarray/boolean_ops.c.src
index 4641f2089..da39824f0 100644
--- a/numpy/core/src/multiarray/boolean_ops.c.src
+++ b/numpy/core/src/multiarray/boolean_ops.c.src
@@ -29,21 +29,30 @@
/* Typedef for the reduction inner loop */
typedef void (reduce_inner_loop)(char **, npy_intp *, npy_intp);
+/**begin repeat
+ * #oper = any, all#
+ * #Oper = Any, All#
+ * #Identity = Zero, One#
+ * #combineop = |=, &=#
+ * #shortcircuit = !value, value#
+ * #idval = 0, 1#
+ */
+
static int
-assign_identity_any(PyArrayObject *result, int preservena, void *data)
+assign_identity_@oper@(PyArrayObject *result, int preservena, void *data)
{
- return PyArray_AssignZero(result, NULL, preservena, NULL);
+ return PyArray_Assign@Identity@(result, NULL, preservena, NULL);
}
static void
-any_inner_gen_gen(char **dataptr, npy_intp *strides, npy_intp count)
+@oper@_inner_gen_gen(char **dataptr, npy_intp *strides, npy_intp count)
{
char *data0 = dataptr[0], *data1 = dataptr[1];
npy_intp stride0 = strides[0], stride1 = strides[1];
npy_intp i;
for (i = 0; i < count; ++i) {
- *data0 |= *data1;
+ *data0 @combineop@ *data1;
data0 += stride0;
data1 += stride1;
@@ -51,15 +60,15 @@ any_inner_gen_gen(char **dataptr, npy_intp *strides, npy_intp count)
}
static void
-any_inner_0stride_gen(char **dataptr, npy_intp *strides, npy_intp count)
+@oper@_inner_0stride_gen(char **dataptr, npy_intp *strides, npy_intp count)
{
char *data0 = dataptr[0], *data1 = dataptr[1];
npy_intp stride1 = strides[1];
npy_intp i;
char value = *data0;
- for (i = 0; i < count && !value; ++i) {
- value |= *data1;
+ for (i = 0; i < count && @shortcircuit@; ++i) {
+ value @combineop@ *data1;
data1 += stride1;
}
@@ -68,24 +77,24 @@ any_inner_0stride_gen(char **dataptr, npy_intp *strides, npy_intp count)
}
static void
-any_inner_0stride_contig(char **dataptr, npy_intp *strides, npy_intp count)
+@oper@_inner_0stride_contig(char **dataptr, npy_intp *strides, npy_intp count)
{
char *data0 = dataptr[0], *data1 = dataptr[1];
char value = *data0;
- if (count > 0 && !value && memchr(data1, 1, count) != NULL) {
- *(npy_bool *)data0 = 1;
+ if (@shortcircuit@ && memchr(data1, 1-@idval@, count) != NULL) {
+ *(npy_bool *)data0 = 1-@idval@;
}
}
static void
-any_inner_contig_contig(char **dataptr, npy_intp *strides, npy_intp count)
+@oper@_inner_contig_contig(char **dataptr, npy_intp *strides, npy_intp count)
{
char *data0 = dataptr[0], *data1 = dataptr[1];
npy_intp i;
for (i = 0; i < count; ++i) {
- *data0 |= *data1;
+ *data0 @combineop@ *data1;
++data0;
++data1;
@@ -93,7 +102,7 @@ any_inner_contig_contig(char **dataptr, npy_intp *strides, npy_intp count)
}
static int
-reduce_any_loop(NpyIter *iter,
+reduce_@oper@_loop(NpyIter *iter,
char **dataptr,
npy_intp *strides,
npy_intp *countptr,
@@ -115,18 +124,18 @@ reduce_any_loop(NpyIter *iter,
/* Choose a loop specialized based on the strides */
if (fixed_strides[0] == 0) {
if (fixed_strides[1] == 1) {
- inner_loop = &any_inner_0stride_contig;
+ inner_loop = &@oper@_inner_0stride_contig;
}
else {
- inner_loop = &any_inner_0stride_gen;
+ inner_loop = &@oper@_inner_0stride_gen;
}
}
else {
if (fixed_strides[0] == 1 && fixed_strides[1] == 1) {
- inner_loop = &any_inner_contig_contig;
+ inner_loop = &@oper@_inner_contig_contig;
}
else {
- inner_loop = &any_inner_gen_gen;
+ inner_loop = &@oper@_inner_gen_gen;
}
}
@@ -147,7 +156,7 @@ reduce_any_loop(NpyIter *iter,
}
static void
-any_masked_inner_gen_gen_gen(char **dataptr,
+@oper@_masked_inner_gen_gen_gen(char **dataptr,
npy_intp *strides, npy_intp count)
{
char *data0 = dataptr[0], *data1 = dataptr[1], *data2 = dataptr[2];
@@ -155,7 +164,7 @@ any_masked_inner_gen_gen_gen(char **dataptr,
npy_intp i;
for (i = 0; i < count; ++i) {
- *data0 |= *data1 & *data2;
+ *data0 @combineop@ *data1 & *data2;
data0 += stride0;
data1 += stride1;
@@ -164,7 +173,7 @@ any_masked_inner_gen_gen_gen(char **dataptr,
}
static void
-any_masked_inner_0stride_gen_gen(char **dataptr,
+@oper@_masked_inner_0stride_gen_gen(char **dataptr,
npy_intp *strides, npy_intp count)
{
char *data0 = dataptr[0], *data1 = dataptr[1], *data2 = dataptr[2];
@@ -172,8 +181,8 @@ any_masked_inner_0stride_gen_gen(char **dataptr,
npy_intp i;
char value = *data0;
- for (i = 0; i < count && !value; ++i) {
- value |= *data1 & *data2;
+ for (i = 0; i < count && @shortcircuit@; ++i) {
+ value @combineop@ *data1 & *data2;
data1 += stride1;
data2 += stride2;
@@ -183,25 +192,29 @@ any_masked_inner_0stride_gen_gen(char **dataptr,
}
static void
-any_masked_inner_0stride_gen_0stride(char **dataptr,
+@oper@_masked_inner_0stride_gen_0stride(char **dataptr,
npy_intp *strides, npy_intp count)
{
char *data0 = dataptr[0], *data1 = dataptr[1], *data2 = dataptr[2];
npy_intp stride1 = strides[1];
npy_intp i;
- char value = *data0, maskvalue = *data2;
+ char maskvalue = *data2;
- for (i = 0; i < count && !value; ++i) {
- value |= *data1 & maskvalue;
+ if (maskvalue) {
+ char value = *data0;
- data1 += stride1;
- }
+ for (i = 0; i < count && @shortcircuit@; ++i) {
+ value @combineop@ *data1;
- *(npy_bool *)data0 = value;
+ data1 += stride1;
+ }
+
+ *(npy_bool *)data0 = value;
+ }
}
static int
-reduce_any_masked_loop(NpyIter *iter,
+reduce_@oper@_masked_loop(NpyIter *iter,
char **dataptr,
npy_intp *strides,
npy_intp *countptr,
@@ -223,14 +236,14 @@ reduce_any_masked_loop(NpyIter *iter,
/* Choose a loop specialized based on the strides */
if (fixed_strides[0] == 0) {
if (fixed_strides[2] == 0) {
- inner_loop = &any_masked_inner_0stride_gen_0stride;
+ inner_loop = &@oper@_masked_inner_0stride_gen_0stride;
}
else {
- inner_loop = &any_masked_inner_0stride_gen_gen;
+ inner_loop = &@oper@_masked_inner_0stride_gen_gen;
}
}
else {
- inner_loop = &any_masked_inner_gen_gen_gen;
+ inner_loop = &@oper@_masked_inner_gen_gen_gen;
}
/*
@@ -250,7 +263,7 @@ reduce_any_masked_loop(NpyIter *iter,
}
static void
-any_adv_masked_inner_gen_gen_gen_gen(char **dataptr,
+@oper@_adv_masked_inner_gen_gen_gen_gen(char **dataptr,
npy_intp *strides, npy_intp count)
{
char *data0 = dataptr[0], *data1 = dataptr[1];
@@ -262,12 +275,15 @@ any_adv_masked_inner_gen_gen_gen_gen(char **dataptr,
for (i = 0; i < count; ++i) {
/* Normal case */
if (*data2) {
- *data0 |= *data1;
+ *data0 @combineop@ *data1;
}
- /* If the value is an exposed True, expose the result as well */
+ /*
+ * If the value is an exposed True (for any) or False (for all),
+ * expose the result as well
+ */
else if (*data1 & *data3) {
- *data0 = 1;
- *data2 = 1;
+ *data0 = 1-@idval@;
+ *data2 = 1-@idval@;
}
data0 += stride0;
@@ -278,7 +294,7 @@ any_adv_masked_inner_gen_gen_gen_gen(char **dataptr,
}
static void
-any_adv_masked_inner_0stride_gen_0stride_gen(char **dataptr,
+@oper@_adv_masked_inner_0stride_gen_0stride_gen(char **dataptr,
npy_intp *strides, npy_intp count)
{
char *data0 = dataptr[0], *data1 = dataptr[1];
@@ -288,15 +304,18 @@ any_adv_masked_inner_0stride_gen_0stride_gen(char **dataptr,
char maskvalue = *data2;
char value = maskvalue ? *data0 : 0;
- for (i = 0; i < count && !value; ++i) {
+ for (i = 0; i < count && @shortcircuit@; ++i) {
/* Normal case */
if (maskvalue) {
- value |= *data1;
+ value @combineop@ *data1;
}
- /* If the value is an exposed True, expose the result as well */
+ /*
+ * If the value is an exposed True (for any) or False (for all),
+ * expose the result as well
+ */
else if (*data1 & *data3) {
- value = 1;
- maskvalue = 1;
+ value = 1-@idval@;
+ maskvalue = 1-@idval@;
break;
}
@@ -311,7 +330,7 @@ any_adv_masked_inner_0stride_gen_0stride_gen(char **dataptr,
}
static int
-reduce_any_advanced_masked_loop(NpyIter *iter,
+reduce_@oper@_advanced_masked_loop(NpyIter *iter,
char **dataptr,
npy_intp *strides,
npy_intp *countptr,
@@ -332,10 +351,10 @@ reduce_any_advanced_masked_loop(NpyIter *iter,
/* Choose a loop specialized based on the strides */
if (fixed_strides[0] == 0 && fixed_strides[2] == 0) {
- inner_loop = &any_adv_masked_inner_0stride_gen_0stride_gen;
+ inner_loop = &@oper@_adv_masked_inner_0stride_gen_0stride_gen;
}
else {
- inner_loop = &any_adv_masked_inner_gen_gen_gen_gen;
+ inner_loop = &@oper@_adv_masked_inner_gen_gen_gen_gen;
}
/*
@@ -355,7 +374,7 @@ reduce_any_advanced_masked_loop(NpyIter *iter,
}
NPY_NO_EXPORT PyArrayObject *
-PyArray_ReduceAny(PyArrayObject *arr, PyArrayObject *out,
+PyArray_Reduce@Oper@(PyArrayObject *arr, PyArrayObject *out,
npy_bool *axis_flags, int skipna, int keepdims)
{
PyArrayObject *result;
@@ -370,11 +389,13 @@ PyArray_ReduceAny(PyArrayObject *arr, PyArrayObject *out,
bool_dtype, bool_dtype,
NPY_UNSAFE_CASTING,
axis_flags, 1, skipna, NULL, keepdims, 1,
- &assign_identity_any,
- &reduce_any_loop,
- &reduce_any_masked_loop,
- &reduce_any_advanced_masked_loop,
- NULL, 0, "any");
+ &assign_identity_@oper@,
+ &reduce_@oper@_loop,
+ &reduce_@oper@_masked_loop,
+ &reduce_@oper@_advanced_masked_loop,
+ NULL, 0, "@oper@");
Py_DECREF(bool_dtype);
return result;
}
+
+/**end repeat**/
diff --git a/numpy/core/src/multiarray/boolean_ops.h b/numpy/core/src/multiarray/boolean_ops.h
index b3cf41a6d..a6674e2aa 100644
--- a/numpy/core/src/multiarray/boolean_ops.h
+++ b/numpy/core/src/multiarray/boolean_ops.h
@@ -5,5 +5,9 @@ NPY_NO_EXPORT PyArrayObject *
PyArray_ReduceAny(PyArrayObject *arr, PyArrayObject *out,
npy_bool *axis_flags, int skipna, int keepdims);
+NPY_NO_EXPORT PyArrayObject *
+PyArray_ReduceAll(PyArrayObject *arr, PyArrayObject *out,
+ npy_bool *axis_flags, int skipna, int keepdims);
+
#endif
diff --git a/numpy/core/src/multiarray/conversion_utils.c b/numpy/core/src/multiarray/conversion_utils.c
index 2090df2f0..0e95bf671 100644
--- a/numpy/core/src/multiarray/conversion_utils.c
+++ b/numpy/core/src/multiarray/conversion_utils.c
@@ -225,6 +225,7 @@ PyArray_ConvertMultiAxis(PyObject *axis_in, int ndim, npy_bool *out_axis_flags)
for (i = 0; i < naxes; ++i) {
PyObject *tmp = PyTuple_GET_ITEM(axis_in, i);
long axis = PyInt_AsLong(tmp);
+ long axis_orig = axis;
if (axis == -1 && PyErr_Occurred()) {
return NPY_FAIL;
}
@@ -232,8 +233,9 @@ PyArray_ConvertMultiAxis(PyObject *axis_in, int ndim, npy_bool *out_axis_flags)
axis += ndim;
}
if (axis < 0 || axis >= ndim) {
- PyErr_SetString(PyExc_ValueError,
- "'axis' entry is out of bounds");
+ PyErr_Format(PyExc_ValueError,
+ "'axis' entry %ld is out of bounds [-%d, %d)",
+ axis_orig, ndim, ndim);
return NPY_FAIL;
}
if (out_axis_flags[axis]) {
@@ -248,11 +250,12 @@ PyArray_ConvertMultiAxis(PyObject *axis_in, int ndim, npy_bool *out_axis_flags)
}
/* Try to interpret axis as an integer */
else {
- long axis;
+ long axis, axis_orig;
memset(out_axis_flags, 0, ndim);
axis = PyInt_AsLong(axis_in);
+ axis_orig = axis;
/* TODO: PyNumber_Index would be good to use here */
if (axis == -1 && PyErr_Occurred()) {
return NPY_FAIL;
@@ -261,16 +264,17 @@ PyArray_ConvertMultiAxis(PyObject *axis_in, int ndim, npy_bool *out_axis_flags)
axis += ndim;
}
/*
- * Special case letting axis=0 slip through for scalars,
+ * Special case letting axis={-1,0} slip through for scalars,
* for backwards compatibility reasons.
*/
- if (axis == 0 && ndim == 0) {
+ if (ndim == 0 && (axis == 0 || axis == -1)) {
return NPY_SUCCEED;
}
if (axis < 0 || axis >= ndim) {
- PyErr_SetString(PyExc_ValueError,
- "'axis' entry is out of bounds");
+ PyErr_Format(PyExc_ValueError,
+ "'axis' entry %ld is out of bounds [-%d, %d)",
+ axis_orig, ndim, ndim);
return NPY_FAIL;
}
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c
index eb57e6db4..7503a5c0a 100644
--- a/numpy/core/src/multiarray/methods.c
+++ b/numpy/core/src/multiarray/methods.c
@@ -2005,7 +2005,7 @@ array_any(PyArrayObject *array, PyObject *args, PyObject *kwds)
int skipna = 0, keepdims = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds,
- "|OO&ii:count_reduce_items", kwlist,
+ "|OO&ii:any", kwlist,
&axis_in,
&PyArray_OutputConverter, &out,
&skipna,
@@ -2015,7 +2015,6 @@ array_any(PyArrayObject *array, PyObject *args, PyObject *kwds)
if (PyArray_ConvertMultiAxis(axis_in, PyArray_NDIM(array),
axis_flags) != NPY_SUCCEED) {
- Py_DECREF(array);
return NULL;
}
@@ -2031,9 +2030,38 @@ array_any(PyArrayObject *array, PyObject *args, PyObject *kwds)
static PyObject *
-array_all(PyArrayObject *self, PyObject *args, PyObject *kwds)
+array_all(PyArrayObject *array, PyObject *args, PyObject *kwds)
{
- NPY_FORWARD_NDARRAY_METHOD("_all");
+ static char *kwlist[] = {"axis", "out", "skipna", "keepdims", NULL};
+
+ PyObject *axis_in = NULL;
+ PyArrayObject *out = NULL;
+ PyArrayObject *ret = NULL;
+ npy_bool axis_flags[NPY_MAXDIMS];
+ int skipna = 0, keepdims = 0;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds,
+ "|OO&ii:all", kwlist,
+ &axis_in,
+ &PyArray_OutputConverter, &out,
+ &skipna,
+ &keepdims)) {
+ return NULL;
+ }
+
+ if (PyArray_ConvertMultiAxis(axis_in, PyArray_NDIM(array),
+ axis_flags) != NPY_SUCCEED) {
+ return NULL;
+ }
+
+ ret = PyArray_ReduceAll(array, out, axis_flags, skipna, keepdims);
+
+ if (out == NULL) {
+ return PyArray_Return(ret);
+ }
+ else {
+ return (PyObject *)ret;
+ }
}
static PyObject *
diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py
index bad78bbea..725047d75 100644
--- a/numpy/core/tests/test_ufunc.py
+++ b/numpy/core/tests/test_ufunc.py
@@ -505,6 +505,17 @@ class TestUfunc(TestCase):
assert_raises(ValueError, np.max, [])
assert_raises(ValueError, np.min, [])
+ def test_axis_out_of_bounds(self):
+ a = np.array([False, False])
+ assert_raises(ValueError, a.all, axis=1)
+ a = np.array([False, False])
+ assert_raises(ValueError, a.all, axis=-2)
+
+ a = np.array([False, False])
+ assert_raises(ValueError, a.any, axis=1)
+ a = np.array([False, False])
+ assert_raises(ValueError, a.any, axis=-2)
+
def test_scalar_reduction(self):
# The functions 'sum', 'prod', etc allow specifying axis=0
# even for scalars
@@ -560,8 +571,8 @@ class TestUfunc(TestCase):
np.add(a, b, out=c, where=[1,0,0,1,0,0,1,1,1,0])
assert_equal(c, [2,1.5,1.5,2,1.5,1.5,2,2,2,1.5])
- def check_unitless_reduction(self, a):
- # np.minimum.reduce is a unitless reduction
+ def check_identityless_reduction(self, a):
+ # np.minimum.reduce is a identityless reduction
# Verify that it sees the zero at various positions
a[...] = 1
@@ -606,31 +617,31 @@ class TestUfunc(TestCase):
[[0,1,1], [1,1,1]])
assert_equal(np.minimum.reduce(a, axis=()), a)
- def test_unitless_reduction_corder(self):
+ def test_identityless_reduction_corder(self):
a = np.empty((2,3,4), order='C')
- self.check_unitless_reduction(a)
+ self.check_identityless_reduction(a)
- def test_unitless_reduction_forder(self):
+ def test_identityless_reduction_forder(self):
a = np.empty((2,3,4), order='F')
- self.check_unitless_reduction(a)
+ self.check_identityless_reduction(a)
- def test_unitless_reduction_otherorder(self):
+ def test_identityless_reduction_otherorder(self):
a = np.empty((2,4,3), order='C').swapaxes(1,2)
- self.check_unitless_reduction(a)
+ self.check_identityless_reduction(a)
- def test_unitless_reduction_noncontig(self):
+ def test_identityless_reduction_noncontig(self):
a = np.empty((3,5,4), order='C').swapaxes(1,2)
a = a[1:, 1:, 1:]
- self.check_unitless_reduction(a)
+ self.check_identityless_reduction(a)
- def test_unitless_reduction_noncontig_unaligned(self):
+ def test_identityless_reduction_noncontig_unaligned(self):
a = np.empty((3*4*5*8 + 1,), dtype='i1')
a = a[1:].view(dtype='f8')
a.shape = (3,4,5)
a = a[1:, 1:, 1:]
- self.check_unitless_reduction(a)
+ self.check_identityless_reduction(a)
- def test_unitless_reduction_nonreorderable(self):
+ def test_identityless_reduction_nonreorderable(self):
a = np.array([[8.0, 2.0, 2.0], [1.0, 0.5, 0.25]])
res = np.divide.reduce(a, axis=0)
diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py
index 0a3f1e3e3..3d2d1e983 100644
--- a/numpy/lib/tests/test_recfunctions.py
+++ b/numpy/lib/tests/test_recfunctions.py
@@ -626,7 +626,7 @@ class TestJoinBy2(TestCase):
dtype=[('a', int), ('b', int), ('d', int)])
def test_no_r1postfix(self):
- "Basic test of join_by"
+ "Basic test of join_by no_r1postfix"
a, b = self.a, self.b
test = join_by('a', a, b, r1postfix='', r2postfix='2', jointype='inner')
@@ -644,7 +644,7 @@ class TestJoinBy2(TestCase):
self.assertRaises(ValueError, join_by, 'a', self.a, self.b, r1postfix='', r2postfix='')
def test_no_r2postfix(self):
- "Basic test of join_by"
+ "Basic test of join_by no_r2postfix"
a, b = self.a, self.b
test = join_by('a', a, b, r1postfix='1', r2postfix='', jointype='inner')