summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorMark Wiebe <mwiebe@enthought.com>2011-07-26 12:14:21 -0500
committerMark Wiebe <mwiebe@enthought.com>2011-07-26 12:14:21 -0500
commit9163993794f1bc56c279ab3d90796370d6b579c4 (patch)
treef5a40b3c0ca60bf9d7a645073e0600e36ccdd60f /numpy/lib
parent1b62bdfb04e56f75fc61dbbd1f2600a72951b19d (diff)
parentaffea42d886e8233fdd6f3c5760708e3a9e9b1b8 (diff)
downloadnumpy-9163993794f1bc56c279ab3d90796370d6b579c4.tar.gz
Merge branch 'deprecate_array_field_access'
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/npyio.py4
-rw-r--r--numpy/lib/src/_compiled_base.c163
-rw-r--r--numpy/lib/tests/test_index_tricks.py2
-rw-r--r--numpy/lib/tests/test_recfunctions.py5
-rw-r--r--numpy/lib/tests/test_stride_tricks.py31
5 files changed, 112 insertions, 93 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 13f659d70..f7cde270d 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -627,7 +627,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None,
data-type, arrays are returned for each field. Default is False.
ndmin : int, optional
The returned array will have at least `ndmin` dimensions.
- Otherwise mono-dimensional axes will be squeezed.
+ Otherwise mono-dimensional axes will be squeezed.
Legal values: 0 (default), 1 or 2.
.. versionadded:: 1.6.0
@@ -803,7 +803,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None,
fh.close()
X = np.array(X, dtype)
- # Multicolumn data are returned with shape (1, N, M), i.e.
+ # Multicolumn data are returned with shape (1, N, M), i.e.
# (1, 1, M) for a single row - remove the singleton dimension there
if X.ndim == 3 and X.shape[:2] == (1, 1):
X.shape = (1, -1)
diff --git a/numpy/lib/src/_compiled_base.c b/numpy/lib/src/_compiled_base.c
index 066519bf1..ea7205a8a 100644
--- a/numpy/lib/src/_compiled_base.c
+++ b/numpy/lib/src/_compiled_base.c
@@ -1,12 +1,13 @@
+#define NPY_NO_DEPRECATED_API
#include "Python.h"
#include "structmember.h"
#include "numpy/noprefix.h"
#include "npy_config.h"
-static intp
-incr_slot_(double x, double *bins, intp lbins)
+static npy_intp
+incr_slot_(double x, double *bins, npy_intp lbins)
{
- intp i;
+ npy_intp i;
for ( i = 0; i < lbins; i ++ ) {
if ( x < bins [i] ) {
@@ -16,10 +17,10 @@ incr_slot_(double x, double *bins, intp lbins)
return lbins;
}
-static intp
-decr_slot_(double x, double * bins, intp lbins)
+static npy_intp
+decr_slot_(double x, double * bins, npy_intp lbins)
{
- intp i;
+ npy_intp i;
for ( i = lbins - 1; i >= 0; i -- ) {
if (x < bins [i]) {
@@ -57,11 +58,11 @@ monotonic_(double * a, int lena)
/* find the index of the maximum element of an integer array */
-static intp
-mxx (intp *i , intp len)
+static npy_intp
+mxx (npy_intp *i , npy_intp len)
{
- intp mx = 0, max = i[0];
- intp j;
+ npy_intp mx = 0, max = i[0];
+ npy_intp j;
for ( j = 1; j < len; j ++ ) {
if ( i [j] > max ) {
@@ -73,11 +74,11 @@ mxx (intp *i , intp len)
}
/* find the index of the minimum element of an integer array */
-static intp
-mnx (intp *i , intp len)
+static npy_intp
+mnx (npy_intp *i , npy_intp len)
{
- intp mn = 0, min = i [0];
- intp j;
+ npy_intp mn = 0, min = i [0];
+ npy_intp j;
for ( j = 1; j < len; j ++ )
if ( i [j] < min )
@@ -105,8 +106,8 @@ arr_bincount(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
{
PyArray_Descr *type;
PyObject *list = NULL, *weight=Py_None, *mlength=Py_None;
- PyObject *lst=NULL, *ans=NULL, *wts=NULL;
- intp *numbers, *ians, len , mxi, mni, ans_size, minlength;
+ PyArrayObject *lst=NULL, *ans=NULL, *wts=NULL;
+ npy_intp *numbers, *ians, len , mxi, mni, ans_size, minlength;
int i;
double *weights , *dans;
static char *kwlist[] = {"list", "weights", "minlength", NULL};
@@ -115,8 +116,9 @@ arr_bincount(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
kwlist, &list, &weight, &mlength)) {
goto fail;
}
- if (!(lst = PyArray_ContiguousFromAny(list, PyArray_INTP, 1, 1))) {
- goto fail;
+ lst = (PyArrayObject *)PyArray_ContiguousFromAny(list, NPY_INTP, 1, 1);
+ if (lst == NULL) {
+ goto fail;
}
len = PyArray_SIZE(lst);
if (len < 1) {
@@ -124,7 +126,7 @@ arr_bincount(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
"The first argument cannot be empty.");
goto fail;
}
- numbers = (intp *) PyArray_DATA(lst);
+ numbers = (npy_intp *) PyArray_DATA(lst);
mxi = mxx(numbers, len);
mni = mnx(numbers, len);
if (numbers[mni] < 0) {
@@ -147,18 +149,21 @@ arr_bincount(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
ans_size = minlength;
}
}
- type = PyArray_DescrFromType(PyArray_INTP);
+ type = PyArray_DescrFromType(NPY_INTP);
if (weight == Py_None) {
- if (!(ans = PyArray_Zeros(1, &ans_size, type, 0))) {
+ ans = (PyArrayObject *)PyArray_Zeros(1, &ans_size, type, 0);
+ if (ans == NULL) {
goto fail;
}
- ians = (intp *)(PyArray_DATA(ans));
+ ians = (npy_intp *)(PyArray_DATA(ans));
for (i = 0; i < len; i++)
ians [numbers [i]] += 1;
Py_DECREF(lst);
}
else {
- if (!(wts = PyArray_ContiguousFromAny(weight, PyArray_DOUBLE, 1, 1))) {
+ wts = (PyArrayObject *)PyArray_ContiguousFromAny(
+ weight, NPY_DOUBLE, 1, 1);
+ if (wts == NULL) {
goto fail;
}
weights = (double *)PyArray_DATA (wts);
@@ -167,18 +172,19 @@ arr_bincount(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
"The weights and list don't have the same length.");
goto fail;
}
- type = PyArray_DescrFromType(PyArray_DOUBLE);
- if (!(ans = PyArray_Zeros(1, &ans_size, type, 0))) {
+ type = PyArray_DescrFromType(NPY_DOUBLE);
+ ans = (PyArrayObject *)PyArray_Zeros(1, &ans_size, type, 0);
+ if (ans == NULL) {
goto fail;
}
- dans = (double *)PyArray_DATA (ans);
+ dans = (double *)PyArray_DATA(ans);
for (i = 0; i < len; i++) {
dans[numbers[i]] += weights[i];
}
Py_DECREF(lst);
Py_DECREF(wts);
}
- return ans;
+ return (PyObject *)ans;
fail:
Py_XDECREF(lst);
@@ -200,10 +206,10 @@ arr_digitize(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
{
/* self is not used */
PyObject *ox, *obins;
- PyObject *ax = NULL, *abins = NULL, *aret = NULL;
+ PyArrayObject *ax = NULL, *abins = NULL, *aret = NULL;
double *dx, *dbins;
- intp lbins, lx; /* lengths */
- intp *iret;
+ npy_intp lbins, lx; /* lengths */
+ npy_intp *iret;
int m, i;
static char *kwlist[] = {"x", "bins", NULL};
PyArray_Descr *type;
@@ -211,12 +217,16 @@ arr_digitize(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &ox, &obins)) {
goto fail;
}
- type = PyArray_DescrFromType(PyArray_DOUBLE);
- if (!(ax = PyArray_FromAny(ox, type, 1, 1, CARRAY, NULL))) {
+ type = PyArray_DescrFromType(NPY_DOUBLE);
+ ax = (PyArrayObject *)PyArray_FromAny(ox, type,
+ 1, 1, NPY_ARRAY_CARRAY, NULL);
+ if (ax == NULL) {
goto fail;
}
Py_INCREF(type);
- if (!(abins = PyArray_FromAny(obins, type, 1, 1, CARRAY, NULL))) {
+ abins = (PyArrayObject *)PyArray_FromAny(obins, type,
+ 1, 1, NPY_ARRAY_CARRAY, NULL);
+ if (abins == NULL) {
goto fail;
}
@@ -224,10 +234,11 @@ arr_digitize(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
dx = (double *)PyArray_DATA(ax);
lbins = PyArray_SIZE(abins);
dbins = (double *)PyArray_DATA(abins);
- if (!(aret = PyArray_SimpleNew(1, &lx, PyArray_INTP))) {
+ aret = (PyArrayObject *)PyArray_SimpleNew(1, &lx, NPY_INTP);
+ if (aret == NULL) {
goto fail;
}
- iret = (intp *)PyArray_DATA(aret);
+ iret = (npy_intp *)PyArray_DATA(aret);
if (lx <= 0 || lbins < 0) {
PyErr_SetString(PyExc_ValueError,
@@ -266,7 +277,7 @@ arr_digitize(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
Py_DECREF(ax);
Py_DECREF(abins);
- return aret;
+ return (PyObject *)aret;
fail:
Py_XDECREF(ax);
@@ -291,7 +302,7 @@ arr_insert(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwdict)
int numvals, totmask, sameshape;
char *input_data, *mptr, *vptr, *zero = NULL;
int melsize, delsize, copied, nd;
- intp *instrides, *inshape;
+ npy_intp *instrides, *inshape;
int mindx, rem_indx, indx, i, k, objarray;
static char *kwlist[] = {"input", "mask", "vals", NULL};
@@ -302,13 +313,13 @@ arr_insert(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwdict)
goto fail;
}
- amask = (PyArrayObject *) PyArray_FROM_OF(mask, CARRAY);
+ amask = (PyArrayObject *)PyArray_FROM_OF(mask, NPY_ARRAY_CARRAY);
if (amask == NULL) {
goto fail;
}
/* Cast an object array */
- if (amask->descr->type_num == PyArray_OBJECT) {
- tmp = (PyArrayObject *)PyArray_Cast(amask, PyArray_INTP);
+ if (PyArray_DESCR(amask)->type_num == NPY_OBJECT) {
+ tmp = (PyArrayObject *)PyArray_Cast(amask, NPY_INTP);
if (tmp == NULL) {
goto fail;
}
@@ -317,16 +328,16 @@ arr_insert(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwdict)
}
sameshape = 1;
- if (amask->nd == ainput->nd) {
- for (k = 0; k < amask->nd; k++) {
- if (amask->dimensions[k] != ainput->dimensions[k]) {
+ if (PyArray_NDIM(amask) == PyArray_NDIM(ainput)) {
+ for (k = 0; k < PyArray_NDIM(amask); k++) {
+ if (PyArray_DIMS(amask)[k] != PyArray_DIMS(ainput)[k]) {
sameshape = 0;
}
}
}
else {
/* Test to see if amask is 1d */
- if (amask->nd != 1) {
+ if (PyArray_NDIM(amask) != 1) {
sameshape = 0;
}
else if ((PyArray_SIZE(ainput)) != PyArray_SIZE(amask)) {
@@ -339,22 +350,23 @@ arr_insert(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwdict)
goto fail;
}
- avals = (PyArrayObject *)PyArray_FromObject(vals, ainput->descr->type_num, 0, 1);
+ avals = (PyArrayObject *)PyArray_FromObject(vals,
+ PyArray_DESCR(ainput)->type_num, 0, 1);
if (avals == NULL) {
goto fail;
}
numvals = PyArray_SIZE(avals);
- nd = ainput->nd;
- input_data = ainput->data;
- mptr = amask->data;
- melsize = amask->descr->elsize;
- vptr = avals->data;
- delsize = avals->descr->elsize;
+ nd = PyArray_NDIM(ainput);
+ input_data = PyArray_DATA(ainput);
+ mptr = PyArray_DATA(amask);
+ melsize = PyArray_DESCR(amask)->elsize;
+ vptr = PyArray_DATA(avals);
+ delsize = PyArray_DESCR(avals)->elsize;
zero = PyArray_Zero(amask);
if (zero == NULL) {
goto fail;
}
- objarray = (ainput->descr->type_num == PyArray_OBJECT);
+ objarray = (PyArray_DESCR(ainput)->type_num == NPY_OBJECT);
/* Handle zero-dimensional case separately */
if (nd == 0) {
@@ -380,8 +392,8 @@ arr_insert(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwdict)
*/
totmask = (int) PyArray_SIZE(amask);
copied = 0;
- instrides = ainput->strides;
- inshape = ainput->dimensions;
+ instrides = PyArray_STRIDES(ainput);
+ inshape = PyArray_DIMS(ainput);
for (mindx = 0; mindx < totmask; mindx++) {
if (memcmp(mptr,zero,melsize) != 0) {
/* compute indx into input array */
@@ -402,7 +414,7 @@ arr_insert(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwdict)
copied += 1;
/* If we move past value data. Reset */
if (copied >= numvals) {
- vptr = avals->data;
+ vptr = PyArray_DATA(avals);
}
}
mptr += melsize;
@@ -476,31 +488,32 @@ arr_interp(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwdict)
return NULL;
}
- afp = (NPY_AO*)PyArray_ContiguousFromAny(fp, NPY_DOUBLE, 1, 1);
+ afp = (PyArrayObject *)PyArray_ContiguousFromAny(fp, NPY_DOUBLE, 1, 1);
if (afp == NULL) {
return NULL;
}
- axp = (NPY_AO*)PyArray_ContiguousFromAny(xp, NPY_DOUBLE, 1, 1);
+ axp = (PyArrayObject *)PyArray_ContiguousFromAny(xp, NPY_DOUBLE, 1, 1);
if (axp == NULL) {
goto fail;
}
- ax = (NPY_AO*)PyArray_ContiguousFromAny(x, NPY_DOUBLE, 1, 0);
+ ax = (PyArrayObject *)PyArray_ContiguousFromAny(x, NPY_DOUBLE, 1, 0);
if (ax == NULL) {
goto fail;
}
- lenxp = axp->dimensions[0];
+ lenxp = PyArray_DIMS(axp)[0];
if (lenxp == 0) {
PyErr_SetString(PyExc_ValueError,
"array of sample points is empty");
goto fail;
}
- if (afp->dimensions[0] != lenxp) {
+ if (PyArray_DIMS(afp)[0] != lenxp) {
PyErr_SetString(PyExc_ValueError,
"fp and xp are not of the same length.");
goto fail;
}
- af = (NPY_AO*)PyArray_SimpleNew(ax->nd, ax->dimensions, NPY_DOUBLE);
+ af = (PyArrayObject *)PyArray_SimpleNew(PyArray_NDIM(ax),
+ PyArray_DIMS(ax), NPY_DOUBLE);
if (af == NULL) {
goto fail;
}
@@ -1038,7 +1051,10 @@ arr_unravel_index(PyObject *self, PyObject *args, PyObject *kwds)
goto fail;
}
Py_INCREF(ret_arr);
- view->base = (PyObject *)ret_arr;
+ if (PyArray_SetBaseObject(view, (PyObject *)ret_arr) < 0) {
+ Py_DECREF(view);
+ goto fail;
+ }
PyTuple_SET_ITEM(ret_tuple, i, PyArray_Return(view));
}
@@ -1246,8 +1262,8 @@ static PyObject *
pack_or_unpack_bits(PyObject *input, int axis, int unpack)
{
PyArrayObject *inp;
- PyObject *new = NULL;
- PyObject *out = NULL;
+ PyArrayObject *new = NULL;
+ PyArrayObject *out = NULL;
npy_intp outdims[MAX_DIMS];
int i;
void (*thefunc)(void *, int, npy_intp, npy_intp, void *, npy_intp, npy_intp);
@@ -1271,25 +1287,25 @@ pack_or_unpack_bits(PyObject *input, int axis, int unpack)
goto fail;
}
- new = PyArray_CheckAxis(inp, &axis, 0);
+ new = (PyArrayObject *)PyArray_CheckAxis(inp, &axis, 0);
Py_DECREF(inp);
if (new == NULL) {
return NULL;
}
/* Handle zero-dim array separately */
if (PyArray_SIZE(new) == 0) {
- return PyArray_Copy((PyArrayObject *)new);
+ return PyArray_Copy(new);
}
if (PyArray_NDIM(new) == 0) {
if (unpack) {
/* Handle 0-d array by converting it to a 1-d array */
- PyObject *temp;
+ PyArrayObject *temp;
PyArray_Dims newdim = {NULL, 1};
npy_intp shape = 1;
newdim.ptr = &shape;
- temp = PyArray_Newshape((PyArrayObject *)new, &newdim, NPY_CORDER);
+ temp = (PyArrayObject *)PyArray_Newshape(new, &newdim, NPY_CORDER);
if (temp == NULL) {
goto fail;
}
@@ -1297,8 +1313,8 @@ pack_or_unpack_bits(PyObject *input, int axis, int unpack)
new = temp;
}
else {
- ubyte *optr, *iptr;
- out = PyArray_New(new->ob_type, 0, NULL, NPY_UBYTE,
+ char *optr, *iptr;
+ out = (PyArrayObject *)PyArray_New(new->ob_type, 0, NULL, NPY_UBYTE,
NULL, NULL, 0, 0, NULL);
if (out == NULL) {
goto fail;
@@ -1338,8 +1354,9 @@ pack_or_unpack_bits(PyObject *input, int axis, int unpack)
}
/* Create output array */
- out = PyArray_New(new->ob_type, PyArray_NDIM(new), outdims, PyArray_UBYTE,
- NULL, NULL, 0, PyArray_ISFORTRAN(new), NULL);
+ out = (PyArrayObject *)PyArray_New(new->ob_type,
+ PyArray_NDIM(new), outdims, NPY_UBYTE,
+ NULL, NULL, 0, PyArray_ISFORTRAN(new), NULL);
if (out == NULL) {
goto fail;
}
@@ -1365,7 +1382,7 @@ pack_or_unpack_bits(PyObject *input, int axis, int unpack)
finish:
Py_DECREF(new);
- return out;
+ return (PyObject *)out;
fail:
Py_XDECREF(new);
diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py
index f0190937b..e4c0bde93 100644
--- a/numpy/lib/tests/test_index_tricks.py
+++ b/numpy/lib/tests/test_index_tricks.py
@@ -48,7 +48,7 @@ class TestRavelUnravelIndex(TestCase):
uncoords = coords[0]+5*coords[1]
assert_equal(np.ravel_multi_index(coords, shape, order='F'), uncoords)
assert_equal(coords, np.unravel_index(uncoords, shape, order='F'))
-
+
coords = np.array([[1,0,1,2,3,4],[1,6,1,3,2,0],[1,3,1,0,9,5]],
dtype=dtype)
shape = (5,8,10)
diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py
index c6befa5f6..0a3f1e3e3 100644
--- a/numpy/lib/tests/test_recfunctions.py
+++ b/numpy/lib/tests/test_recfunctions.py
@@ -671,9 +671,10 @@ class TestJoinBy2(TestCase):
(10, 2, 54, 69, 14, 4), (11, 2, 55, 70, 15, 5),
(10, 3, 56, 71, 16, 6), (11, 3, 57, 72, 17, 7),
(10, 4, 58, 73, 18, 8), (11, 4, 59, 74, 19, 9)],
- dtype=[('k', '<i8'), ('a', '<i8'), ('b1', '<i8'),
- ('b2', '<i8'), ('c1', '<i8'), ('c2', '<i8')])
+ dtype=[('k', int), ('a', int), ('b1', int),
+ ('b2', int), ('c1', int), ('c2', int)])
test = join_by(['a','k'], a, b, r1postfix='1', r2postfix='2', jointype='inner')
+ assert_equal(test.dtype, control.dtype)
assert_equal(test, control)
diff --git a/numpy/lib/tests/test_stride_tricks.py b/numpy/lib/tests/test_stride_tricks.py
index d7cf114f7..814f2d614 100644
--- a/numpy/lib/tests/test_stride_tricks.py
+++ b/numpy/lib/tests/test_stride_tricks.py
@@ -11,7 +11,7 @@ def assert_shapes_correct(input_shapes, expected_shape):
outarrays = broadcast_arrays(*inarrays)
outshapes = [a.shape for a in outarrays]
expected = [expected_shape] * len(inarrays)
- assert_(outshapes == expected)
+ assert_equal(outshapes, expected)
def assert_incompatible_shapes_raise(input_shapes):
""" Broadcast a list of arrays with the given (incompatible) input shapes
@@ -76,13 +76,13 @@ def test_same_input_shapes():
for shape in data:
input_shapes = [shape]
# Single input.
- yield assert_shapes_correct, input_shapes, shape
+ assert_shapes_correct(input_shapes, shape)
# Double input.
input_shapes2 = [shape, shape]
- yield assert_shapes_correct, input_shapes2, shape
+ assert_shapes_correct(input_shapes2, shape)
# Triple input.
input_shapes3 = [shape, shape, shape]
- yield assert_shapes_correct, input_shapes3, shape
+ assert_shapes_correct(input_shapes3, shape)
def test_two_compatible_by_ones_input_shapes():
""" Check that two different input shapes (of the same length but some have
@@ -104,9 +104,9 @@ def test_two_compatible_by_ones_input_shapes():
[[(1,1), (0,1)], (0,1)],
]
for input_shapes, expected_shape in data:
- yield assert_shapes_correct, input_shapes, expected_shape
+ assert_shapes_correct(input_shapes, expected_shape)
# Reverse the input shapes since broadcasting should be symmetric.
- yield assert_shapes_correct, input_shapes[::-1], expected_shape
+ assert_shapes_correct(input_shapes[::-1], expected_shape)
def test_two_compatible_by_prepending_ones_input_shapes():
""" Check that two different input shapes (of different lengths) broadcast
@@ -135,9 +135,9 @@ def test_two_compatible_by_prepending_ones_input_shapes():
[[(), (0,1)], (0,1)],
]
for input_shapes, expected_shape in data:
- yield assert_shapes_correct, input_shapes, expected_shape
+ assert_shapes_correct(input_shapes, expected_shape)
# Reverse the input shapes since broadcasting should be symmetric.
- yield assert_shapes_correct, input_shapes[::-1], expected_shape
+ assert_shapes_correct(input_shapes[::-1], expected_shape)
def test_incompatible_shapes_raise_valueerror():
""" Check that a ValueError is raised for incompatible shapes.
@@ -149,9 +149,9 @@ def test_incompatible_shapes_raise_valueerror():
[(1,3,4), (2,3,3)],
]
for input_shapes in data:
- yield assert_incompatible_shapes_raise, input_shapes
+ assert_incompatible_shapes_raise(input_shapes)
# Reverse the input shapes since broadcasting should be symmetric.
- yield assert_incompatible_shapes_raise, input_shapes[::-1]
+ assert_incompatible_shapes_raise(input_shapes[::-1])
def test_same_as_ufunc():
""" Check that the data layout is the same as if a ufunc did the operation.
@@ -192,16 +192,17 @@ def test_same_as_ufunc():
[[(), (0,1)], (0,1)],
]
for input_shapes, expected_shape in data:
- yield assert_same_as_ufunc, input_shapes[0], input_shapes[1]
+ assert_same_as_ufunc(input_shapes[0], input_shapes[1],
+ "Shapes: %s %s" % (input_shapes[0], input_shapes[1]))
# Reverse the input shapes since broadcasting should be symmetric.
- yield assert_same_as_ufunc, input_shapes[1], input_shapes[0]
+ assert_same_as_ufunc(input_shapes[1], input_shapes[0])
# Try them transposed, too.
- yield assert_same_as_ufunc, input_shapes[0], input_shapes[1], True
+ assert_same_as_ufunc(input_shapes[0], input_shapes[1], True)
# ... and flipped for non-rank-0 inputs in order to test negative
# strides.
if () not in input_shapes:
- yield assert_same_as_ufunc, input_shapes[0], input_shapes[1], False, True
- yield assert_same_as_ufunc, input_shapes[0], input_shapes[1], True, True
+ assert_same_as_ufunc(input_shapes[0], input_shapes[1], False, True)
+ assert_same_as_ufunc(input_shapes[0], input_shapes[1], True, True)
if __name__ == "__main__":