Skip to content

Commit 848ec42

Browse files
committed
Make test_oper_arr() generic over A again
1 parent 7ebbbb8 commit 848ec42

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/oper.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,33 @@ use ndarray::Si;
1111
use ndarray::{Ix, Ixs};
1212

1313
use std::fmt;
14+
use std::ops::Neg;
1415
use num_traits::Float;
1516

1617
fn test_oper(op: &str, a: &[f32], b: &[f32], c: &[f32])
1718
{
1819
let aa = rcarr1(a);
1920
let bb = rcarr1(b);
2021
let cc = rcarr1(c);
21-
test_oper_arr(op, aa.clone(), bb.clone(), cc.clone());
22+
test_oper_arr::<f32, _>(op, aa.clone(), bb.clone(), cc.clone());
2223
let dim = (2, 2);
2324
let aa = aa.reshape(dim);
2425
let bb = bb.reshape(dim);
2526
let cc = cc.reshape(dim);
26-
test_oper_arr(op, aa.clone(), bb.clone(), cc.clone());
27+
test_oper_arr::<f32, _>(op, aa.clone(), bb.clone(), cc.clone());
2728
let dim = (1, 2, 1, 2);
2829
let aa = aa.reshape(dim);
2930
let bb = bb.reshape(dim);
3031
let cc = cc.reshape(dim);
31-
test_oper_arr(op, aa.clone(), bb.clone(), cc.clone());
32+
test_oper_arr::<f32, _>(op, aa.clone(), bb.clone(), cc.clone());
3233
}
3334

34-
fn test_oper_arr<D: Dimension>(
35-
op: &str,
36-
mut aa: RcArray<f32, D>,
37-
bb: RcArray<f32, D>,
38-
cc: RcArray<f32, D>,
39-
) {
35+
fn test_oper_arr<A, D>(op: &str, mut aa: RcArray<A, D>, bb: RcArray<A, D>, cc: RcArray<A, D>)
36+
where
37+
A: NdFloat,
38+
for<'a> &'a A: Neg<Output=A>,
39+
D: Dimension,
40+
{
4041
match op {
4142
"+" => {
4243
assert_eq!(&aa + &bb, cc);

0 commit comments

Comments
 (0)