Skip to content

Commit ee97dbf

Browse files
committed
TEST: Add parallel collect test for small arrays
1 parent 3ab67eb commit ee97dbf

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/par_zip.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,28 @@ fn test_zip_collect() {
9797
assert_abs_diff_eq!(a, &b + &c, epsilon = 1e-6);
9898
assert_eq!(a.strides(), b.strides());
9999
}
100+
101+
}
102+
103+
#[test]
104+
#[cfg(feature = "approx")]
105+
fn test_zip_small_collect() {
106+
use approx::assert_abs_diff_eq;
107+
108+
for m in 0..32 {
109+
for n in 0..16 {
110+
let dim = (m, n);
111+
let b = Array::from_shape_fn(dim, |(i, j)| 1. / (i + 2 * j + 1) as f32);
112+
let c = Array::from_shape_fn(dim, |(i, j)| f32::ln((1 + i + j) as f32));
113+
114+
{
115+
let a = Zip::from(&b).and(&c).par_apply_collect(|x, y| x + y);
116+
117+
assert_abs_diff_eq!(a, &b + &c, epsilon = 1e-6);
118+
assert_eq!(a.strides(), b.strides());
119+
}
120+
}
121+
}
100122
}
101123

102124
#[test]

0 commit comments

Comments
 (0)