Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 33178e9

Browse files
committed
Accept dimension mismatch for empty arrays
1 parent 16c92ad commit 33178e9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/numpy_cpp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,10 @@ class array_view : public detail::array_view_accessors<array_view, T, ND>
447447
return 1;
448448
}
449449
}
450+
if (PyArray_NDIM(tmp) > 0 && PyArray_DIM(tmp, 0) == 0) {
451+
// accept dimension mismatch for empty arrays
452+
return 1;
453+
}
450454
if (PyArray_NDIM(tmp) != ND) {
451455
PyErr_Format(PyExc_ValueError,
452456
"Expected %d-dimensional array, got %d",

0 commit comments

Comments
 (0)