diff options
author | Holger Kohr <kohr@kth.se> | 2015-12-30 12:55:32 +0100 |
---|---|---|
committer | Holger Kohr <kohr@kth.se> | 2016-01-04 11:47:15 +0100 |
commit | 450cb8c2d77a8becdeae30afd90d0ec743e6f3ec (patch) | |
tree | b994ae39ce5a518c18c9670ae277a359f0bcca55 /numpy | |
parent | e072d79f03610c33e336a9b700882d8905f9c958 (diff) | |
download | numpy-450cb8c2d77a8becdeae30afd90d0ec743e6f3ec.tar.gz |
ENH: allow single input argument in numpy.broadcast
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/multiarray/iterators.c | 12 | ||||
-rw-r--r-- | numpy/lib/stride_tricks.py | 3 |
2 files changed, 6 insertions, 9 deletions
diff --git a/numpy/core/src/multiarray/iterators.c b/numpy/core/src/multiarray/iterators.c index 702f9e21a..5099e3e19 100644 --- a/numpy/core/src/multiarray/iterators.c +++ b/numpy/core/src/multiarray/iterators.c @@ -1456,9 +1456,9 @@ PyArray_MultiIterFromObjects(PyObject **mps, int n, int nadd, ...) int i, ntot, err=0; ntot = n + nadd; - if (ntot < 2 || ntot > NPY_MAXARGS) { + if (ntot < 1 || ntot > NPY_MAXARGS) { PyErr_Format(PyExc_ValueError, - "Need at least 2 and at most %d " + "Need at least 1 and at most %d " "array objects.", NPY_MAXARGS); return NULL; } @@ -1522,9 +1522,9 @@ PyArray_MultiIterNew(int n, ...) int i, err = 0; - if (n < 2 || n > NPY_MAXARGS) { + if (n < 1 || n > NPY_MAXARGS) { PyErr_Format(PyExc_ValueError, - "Need at least 2 and at most %d " + "Need at least 1 and at most %d " "array objects.", NPY_MAXARGS); return NULL; } @@ -1603,12 +1603,12 @@ arraymultiter_new(PyTypeObject *NPY_UNUSED(subtype), PyObject *args, PyObject *k ++n; } } - if (n < 2 || n > NPY_MAXARGS) { + if (n < 1 || n > NPY_MAXARGS) { if (PyErr_Occurred()) { return NULL; } PyErr_Format(PyExc_ValueError, - "Need at least 2 and at most %d " + "Need at least 1 and at most %d " "array objects.", NPY_MAXARGS); return NULL; } diff --git a/numpy/lib/stride_tricks.py b/numpy/lib/stride_tricks.py index f4b43a5a9..4c23ab355 100644 --- a/numpy/lib/stride_tricks.py +++ b/numpy/lib/stride_tricks.py @@ -121,9 +121,6 @@ def _broadcast_shape(*args): """ if not args: raise ValueError('must provide at least one argument') - if len(args) == 1: - # a single argument does not work with np.broadcast - return np.asarray(args[0]).shape # use the old-iterator because np.nditer does not handle size 0 arrays # consistently b = np.broadcast(*args[:32]) |