Skip to content

Commit

Permalink
ndarray: fix F-style array acceptance criterion
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Jan 8, 2025
1 parent 0272db4 commit b95eb75
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/nb_ndarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,14 @@ ndarray_handle *ndarray_import(PyObject *o, const ndarray_config *c,
if (!t.strides) {
/* When the provided tensor does not have a valid
strides field, it uses the C ordering convention */
pass_order = c_order || t.ndim == 1;
if (c_order) {
pass_order = true;
} else {
int nontrivial_dims = 0;
for (int i = 0; i < t.ndim; ++i)
nontrivial_dims += (int) (t.shape[i] > 1);
pass_order = nontrivial_dims <= 1;
}
} else {
if (c_order) {
for (int64_t i = t.ndim - 1, accum = 1; i >= 0; --i) {
Expand Down

0 comments on commit b95eb75

Please sign in to comment.