Skip to content

Commit ed2eaf7

Browse files
committed
Generalize .allclose()
1 parent 399e997 commit ed2eaf7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,12 +1442,16 @@ impl<A: Copy + linalg::Ring, S> ArrayBase<S, (Ix, Ix)>
14421442
}
14431443

14441444

1445-
impl<A: Float + PartialOrd, D: Dimension> Array<A, D>
1445+
impl<A, S, D> ArrayBase<S, D>
1446+
where A: Float + PartialOrd,
1447+
S: Data<Elem=A>,
1448+
D: Dimension
14461449
{
14471450
/// Return `true` if the arrays' elementwise differences are all within
14481451
/// the given absolute tolerance.<br>
14491452
/// Return `false` otherwise, or if the shapes disagree.
1450-
pub fn allclose(&self, rhs: &Array<A, D>, tol: A) -> bool
1453+
pub fn allclose<S2>(&self, rhs: &ArrayBase<S2, D>, tol: A) -> bool
1454+
where S2: Data<Elem=A>,
14511455
{
14521456
self.shape() == rhs.shape() &&
14531457
self.iter().zip(rhs.iter()).all(|(x, y)| (*x - *y).abs() <= tol)

0 commit comments

Comments
 (0)