Skip to content

Commit 337d758

Browse files
committed
Add another testcase for outer_iter
1 parent fdca362 commit 337d758

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/iterators.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[macro_use(s)]
12
extern crate ndarray;
23
extern crate itertools;
34

@@ -196,6 +197,23 @@ fn outer_iter() {
196197
}
197198
found_rows_rev.reverse();
198199
assert_eq!(&found_rows, &found_rows_rev);
200+
201+
// Test a case where strides are negative instead
202+
let mut c = Array::zeros((2, 3, 2));
203+
let mut cv = c.slice_mut(s![..;-1, ..;-1, ..;-1]);
204+
cv.assign(&a);
205+
assert_eq!(&a, &cv);
206+
assert_equal(cv.outer_iter(),
207+
vec![a.subview(0, 0), a.subview(0, 1)]);
208+
209+
let mut found_rows = Vec::new();
210+
for sub in cv.outer_iter() {
211+
for row in sub.into_outer_iter() {
212+
found_rows.push(row);
213+
}
214+
}
215+
println!("{:#?}", found_rows);
216+
assert_equal(a.inner_iter(), found_rows);
199217
}
200218

201219
#[test]

0 commit comments

Comments
 (0)