Skip to content

Commit bcf3971

Browse files
committed
Add a test for Zip + the .windows() producer
1 parent fc22783 commit bcf3971

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tests/windows.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11

2+
#[macro_use(s)]
23
extern crate ndarray;
34
extern crate itertools;
45

56
use ndarray::prelude::*;
7+
use ndarray::Zip;
68

79
// Edge Cases for Windows iterator:
810
//
@@ -96,4 +98,28 @@ fn windows_iterator_3d() {
9698
arr3(&[ [[22, 23], [25, 26]], [[31, 32], [34, 35]] ]),
9799
arr3(&[ [[23, 24], [26, 27]], [[32, 33], [35, 36]] ]),
98100
]);
99-
}
101+
}
102+
103+
#[test]
104+
fn test_window_zip() {
105+
let a = Array::from_iter(0..64).into_shape((4, 4, 4)).unwrap();
106+
107+
for x in 1..4 {
108+
for y in 1..4 {
109+
for z in 1..4 {
110+
Zip::indexed(a.windows((x, y, z)))
111+
.apply(|(i, j, k), window| {
112+
let x = x as isize;
113+
let y = y as isize;
114+
let z = z as isize;
115+
let i = i as isize;
116+
let j = j as isize;
117+
let k = k as isize;
118+
assert_eq!(window, a.slice(s![i .. i + x,
119+
j .. j + y,
120+
k .. k + z]));
121+
})
122+
}
123+
}
124+
}
125+
}

0 commit comments

Comments
 (0)