summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Moore <ewm@redtetrahedron.org>2016-02-15 16:44:02 -0500
committerEric Moore <ewm@redtetrahedron.org>2016-03-22 07:55:29 -0400
commit42ba22c1ae84acb4e008b298801e71b4b121689b (patch)
tree99dd4fc02888b120a77fdb25c02ebd1fb26ad350
parent3d2c1baf47d2e1c37c84b8ed297649aa1600cd42 (diff)
downloadnumpy-42ba22c1ae84acb4e008b298801e71b4b121689b.tar.gz
BUG: Don't allow converions of S or U arrays in __complex__
-rw-r--r--numpy/core/src/multiarray/methods.c6
-rw-r--r--numpy/core/tests/test_multiarray.py8
2 files changed, 2 insertions, 12 deletions
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c
index 5348981a7..b8e066b79 100644
--- a/numpy/core/src/multiarray/methods.c
+++ b/numpy/core/src/multiarray/methods.c
@@ -2326,12 +2326,10 @@ array_complex(PyArrayObject *self, PyObject *NPY_UNUSED(args))
}
if (!PyArray_CanCastArrayTo(self, dtype, NPY_SAME_KIND_CASTING) &&
- !(PyArray_TYPE(self) == NPY_OBJECT) &&
- !(PyArray_TYPE(self) == NPY_STRING) &&
- !(PyArray_TYPE(self) == NPY_UNICODE)) {
+ !(PyArray_TYPE(self) == NPY_OBJECT)) {
PyObject *err, *msg_part;
Py_DECREF(dtype);
- err = PyString_FromString("unable to convert dtype: ");
+ err = PyString_FromString("unable to convert ");
if (err == NULL) {
return NULL;
}
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 4850e057c..67c353451 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -2494,14 +2494,6 @@ class TestMethods(TestCase):
cp = complex(c)
assert_equal(cp, c, msg)
- s = np.array([[['1+2j']]], 'S')
- sp = complex(s)
- assert_equal(sp, 1+2j)
-
- u = np.array([[['1+2j']]], 'U')
- up = complex(u)
- assert_equal(up, 1+2j)
-
class TestBinop(object):
def test_inplace(self):