diff options
-rw-r--r-- | numpy/core/src/multiarray/arrayobject.c | 4 | ||||
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c index 68a40f9fd..f696d8b76 100644 --- a/numpy/core/src/multiarray/arrayobject.c +++ b/numpy/core/src/multiarray/arrayobject.c @@ -1029,12 +1029,12 @@ static PyObject * _void_compare(PyArrayObject *self, PyArrayObject *other, int cmp_op) { if (!(cmp_op == Py_EQ || cmp_op == Py_NE)) { - PyErr_SetString(PyExc_ValueError, + PyErr_SetString(PyExc_TypeError, "Void-arrays can only be compared for equality."); return NULL; } if (PyArray_TYPE(other) != NPY_VOID) { - PyErr_SetString(PyExc_ValueError, + PyErr_SetString(PyExc_TypeError, "Cannot compare structured or void to non-void arrays."); return NULL; } diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 40c65b3a9..324e99981 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -1275,8 +1275,9 @@ class TestStructured: with pytest.raises(TypeError): x == y - # Added title prevents promotion: - y = np.zeros(3, dtype=[('a', 'i1', 'title')]) + # Added title prevents promotion, but casts are OK: + y = np.zeros(3, dtype=[(('title', 'a'), 'i1')]) + assert np.can_cast(y.dtype, x.dtype) with pytest.raises(TypeError): x == y |