Skip to content

Commit 54e3a83

Browse files
committed
MNT: check for valid views by comparing with NPY_MIN_INTP
1 parent e16ad3b commit 54e3a83

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

numpy/_core/src/multiarray/ctors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ PyArray_FromArray(PyArrayObject *arr, PyArray_Descr *newtype, int flags)
19281928
if (!copy) {
19291929
npy_intp view_offset;
19301930
npy_intp is_safe = PyArray_SafeCast(oldtype, newtype, &view_offset, NPY_NO_CASTING, 1);
1931-
copy = copy || !(is_safe && (view_offset == 0));
1931+
copy = copy || !(is_safe && (view_offset != NPY_MIN_INTP));
19321932
}
19331933

19341934
if (copy) {

numpy/_core/src/multiarray/multiarraymodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ _array_fromobject_generic(
15941594
oldtype = PyArray_DESCR(oparr);
15951595
npy_intp view_offset;
15961596
npy_intp is_safe = PyArray_SafeCast(oldtype, dtype, &view_offset, NPY_NO_CASTING, 1);
1597-
npy_intp view_safe = (is_safe && (view_offset == 0));
1597+
npy_intp view_safe = (is_safe && (view_offset != NPY_MIN_INTP));
15981598
if (view_safe) {
15991599
if (copy != NPY_COPY_ALWAYS && STRIDING_OK(oparr, order)) {
16001600
if (oldtype == dtype) {

0 commit comments

Comments
 (0)