summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/src/multiarray/ctors.c4
-rw-r--r--numpy/core/src/multiarray/methods.c2
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c4
-rw-r--r--numpy/core/tests/test_api.py2
-rw-r--r--numpy/core/tests/test_multiarray.py4
5 files changed, 8 insertions, 8 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c
index a125ce81f..87406bdbc 100644
--- a/numpy/core/src/multiarray/ctors.c
+++ b/numpy/core/src/multiarray/ctors.c
@@ -1843,7 +1843,7 @@ PyArray_CheckFromAny(PyObject *op, PyArray_Descr *descr, int min_depth,
!PyArray_ElementStrides(obj)) {
PyObject *ret;
if( requires & NPY_ARRAY_ENSURENOCOPY ) {
- PyErr_SetString(PyExc_RuntimeError,
+ PyErr_SetString(PyExc_ValueError,
"Unable to avoid copy while creating a new array.");
return NULL;
}
@@ -1923,7 +1923,7 @@ PyArray_FromArray(PyArrayObject *arr, PyArray_Descr *newtype, int flags)
if (copy) {
if( flags & NPY_ARRAY_ENSURENOCOPY ) {
- PyErr_SetString(PyExc_RuntimeError,
+ PyErr_SetString(PyExc_ValueError,
"Unable to avoid copy while creating "
"an array from given array.");
return NULL;
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c
index d431c6f97..9613bf04e 100644
--- a/numpy/core/src/multiarray/methods.c
+++ b/numpy/core/src/multiarray/methods.c
@@ -869,7 +869,7 @@ array_astype(PyArrayObject *self,
}
if( forcecopy == NPY_NEVER ) {
- PyErr_SetString(PyExc_RuntimeError,
+ PyErr_SetString(PyExc_ValueError,
"Unable to avoid copy while casting in np.CopyMode.NEVER");
Py_DECREF(dtype);
return NULL;
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index edb200700..489c51df3 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -1582,7 +1582,7 @@ _array_fromobject_generic(
}
else {
if( copy == NPY_NEVER ) {
- PyErr_SetString(PyExc_RuntimeError,
+ PyErr_SetString(PyExc_ValueError,
"Unable to avoid copy while creating a new array.");
return NULL;
}
@@ -1601,7 +1601,7 @@ _array_fromobject_generic(
}
else {
if( copy == NPY_NEVER ) {
- PyErr_SetString(PyExc_RuntimeError,
+ PyErr_SetString(PyExc_ValueError,
"Unable to avoid copy while creating a new array.");
return NULL;
}
diff --git a/numpy/core/tests/test_api.py b/numpy/core/tests/test_api.py
index 38261a8c3..3bd01e5b4 100644
--- a/numpy/core/tests/test_api.py
+++ b/numpy/core/tests/test_api.py
@@ -611,4 +611,4 @@ def test_astype_copyflag():
assert_array_equal(res_false, arr)
res_if_needed = arr.astype(np.float64, copy=np.CopyMode.IF_NEEDED)
assert_array_equal(res_if_needed, arr)
- assert_raises(RuntimeError, arr.astype, np.float64, copy=np.CopyMode.NEVER)
+ assert_raises(ValueError, arr.astype, np.float64, copy=np.CopyMode.NEVER)
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 734a7cea3..ba8caddda 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -7792,7 +7792,7 @@ class TestArrayCreationCopyArgument(object):
assert_array_equal(res, arr)
- assert_raises(RuntimeError, np.array,
+ assert_raises(ValueError, np.array,
arr, copy=np.CopyMode.NEVER, dtype=int2)
@@ -7908,7 +7908,7 @@ class TestArrayCreationCopyArgument(object):
for copy in self.false_vals:
res = np.array(arr, copy=copy, order=order2)
assert_array_equal(arr, res)
- assert_raises(RuntimeError, np.array,
+ assert_raises(ValueError, np.array,
view, copy=np.CopyMode.NEVER, order=order2)