Skip to content

Commit ef51f56

Browse files
committed
FIX: For stride == 1 axes, require len > 1 to determine C/F preference
The issue was that otherwise, this array: shape: [1, 256] strides: [1, 256] Which was "correctly" determined to be F-preference because it's sliced out of an f-order array. In reality it is discontiguous; every element is 256 steps from the next. This should have layout None, the same as this array would have (ignoring 1-len axes). shape: [256] strides: [256]
1 parent 5a25def commit ef51f56

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/zip/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ where
6969
} else if n > 1 && self.raw_view().reversed_axes().is_standard_layout() {
7070
Layout::f()
7171
} else if n > 1 {
72-
if self.stride_of(Axis(0)) == 1 {
72+
if self.len_of(Axis(0)) > 1 && self.stride_of(Axis(0)) == 1 {
7373
Layout::fpref()
74-
} else if self.stride_of(Axis(n - 1)) == 1 {
74+
} else if self.len_of(Axis(n - 1)) > 1 && self.stride_of(Axis(n - 1)) == 1 {
7575
Layout::cpref()
7676
} else {
7777
Layout::none()

0 commit comments

Comments
 (0)