Skip to content

Commit 05ff102

Browse files
czgdp1807seberg
andauthored
Apply suggestions from code review
Co-authored-by: Sebastian Berg <[email protected]>
1 parent 5ede7eb commit 05ff102

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

numpy/core/src/multiarray/conversion_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ PyArray_CopyConverter(PyObject *obj, _PyArray_CopyMode *copymode) {
182182
}
183183

184184
int_copymode = PyLong_AsLong(mode_value);
185-
if (int_copymode < 0 || PyErr_Occurred()) {
185+
if (error_converting(int_copymode)) {
186186
return NPY_FAIL;
187187
}
188188
}

numpy/core/src/multiarray/ctors.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,7 @@ PyArray_FromAny(PyObject *op, PyArray_Descr *newtype, int min_depth,
17471747

17481748
/* Create a new array and copy the data */
17491749
Py_INCREF(dtype); /* hold on in case of a subarray that is replaced */
1750-
if( flags & NPY_ARRAY_ENSURENOCOPY ) {
1750+
if (flags & NPY_ARRAY_ENSURENOCOPY ) {
17511751
PyErr_SetString(PyExc_ValueError,
17521752
"Unable to avoid copy while creating "
17531753
"an array from descriptor.");
@@ -1953,11 +1953,9 @@ PyArray_FromArray(PyArrayObject *arr, PyArray_Descr *newtype, int flags)
19531953
!PyArray_EquivTypes(oldtype, newtype);
19541954

19551955
if (copy) {
1956-
1957-
if( flags & NPY_ARRAY_ENSURENOCOPY ) {
1956+
if (flags & NPY_ARRAY_ENSURENOCOPY ) {
19581957
PyErr_SetString(PyExc_ValueError,
1959-
"Unable to avoid copy while creating "
1960-
"an array from given array.");
1958+
"Unable to avoid copy while creating an array from given array.");
19611959
return NULL;
19621960
}
19631961

numpy/core/src/multiarray/multiarraymodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,8 @@ _array_fromobject_generic(
16221622

16231623
if (copy == NPY_COPY_ALWAYS) {
16241624
flags = NPY_ARRAY_ENSURECOPY;
1625-
} else if( copy == NPY_COPY_NEVER ) {
1625+
}
1626+
else if (copy == NPY_COPY_NEVER ) {
16261627
flags = NPY_ARRAY_ENSURENOCOPY;
16271628
}
16281629
if (order == NPY_CORDER) {

0 commit comments

Comments
 (0)