File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -741,6 +741,16 @@ macro_rules! map_impl {
741741 /// Tests if every element of the iterator matches a predicate.
742742 ///
743743 /// Returns `true` if `predicate` evaluates to `true` for all elements.
744+ /// Returns `true` if the input arrays are empty.
745+ ///
746+ /// Example:
747+ ///
748+ /// ```
749+ /// use ndarray::{array, Zip};
750+ /// let a = array![1, 2, 3];
751+ /// let b = array![1, 4, 9];
752+ /// assert!(Zip::from(&a).and(&b).all(|&a, &b| a * a == b));
753+ /// ```
744754 pub fn all<F >( mut self , mut predicate: F ) -> bool
745755 where F : FnMut ( $( $p:: Item ) ,* ) -> bool
746756 {
Original file line number Diff line number Diff line change @@ -276,8 +276,11 @@ fn test_indices_split_1() {
276276fn test_zip_all ( ) {
277277 let a = Array :: < f32 , _ > :: zeros ( 62 ) ;
278278 let b = Array :: < f32 , _ > :: ones ( 62 ) ;
279+ let mut c = Array :: < f32 , _ > :: ones ( 62 ) ;
280+ c[ 5 ] = 0.0 ;
279281 assert_eq ! ( true , Zip :: from( & a) . and( & b) . all( |& x, & y| x + y == 1.0 ) ) ;
280282 assert_eq ! ( false , Zip :: from( & a) . and( & b) . all( |& x, & y| x == y) ) ;
283+ assert_eq ! ( false , Zip :: from( & a) . and( & c) . all( |& x, & y| x + y == 1.0 ) ) ;
281284}
282285
283286#[ test]
You can’t perform that action at this time.
0 commit comments