11use ndarray:: { arr2, arr3, aview1, aview2, concatenate, stack, Array2 , Axis , ErrorKind , Ix1 , ViewRepr } ;
22
33#[ test]
4- fn concatenating ( )
5- {
4+ fn concatenating ( ) {
65 let a = arr2 ( & [ [ 2. , 2. ] , [ 3. , 3. ] ] ) ;
76 let b = ndarray:: concatenate ( Axis ( 0 ) , & [ a. view ( ) , a. view ( ) ] ) . unwrap ( ) ;
87 assert_eq ! ( b, arr2( & [ [ 2. , 2. ] , [ 3. , 3. ] , [ 2. , 2. ] , [ 3. , 3. ] ] ) ) ;
98
109 let c = concatenate ! [ Axis ( 0 ) , a, b] ;
11- assert_eq ! (
12- c,
13- arr2( & [ [ 2. , 2. ] , [ 3. , 3. ] , [ 2. , 2. ] , [ 3. , 3. ] , [ 2. , 2. ] , [ 3. , 3. ] ] )
14- ) ;
10+ assert_eq ! ( c, arr2( & [ [ 2. , 2. ] , [ 3. , 3. ] , [ 2. , 2. ] , [ 3. , 3. ] , [ 2. , 2. ] , [ 3. , 3. ] ] ) ) ;
1511
1612 let d = concatenate ! [ Axis ( 0 ) , a. row( 0 ) , & [ 9. , 9. ] ] ;
1713 assert_eq ! ( d, aview1( & [ 2. , 2. , 9. , 9. ] ) ) ;
1814
1915 let d = concatenate ! [ Axis ( 1 ) , a. row( 0 ) . insert_axis( Axis ( 1 ) ) , aview1( & [ 9. , 9. ] ) . insert_axis( Axis ( 1 ) ) ] ;
20- assert_eq ! ( d, aview2( & [ [ 2. , 9. ] ,
21- [ 2. , 9. ] ] ) ) ;
16+ assert_eq ! ( d, aview2( & [ [ 2. , 9. ] , [ 2. , 9. ] ] ) ) ;
2217
2318 let d = concatenate ! [ Axis ( 0 ) , a. row( 0 ) . insert_axis( Axis ( 1 ) ) , aview1( & [ 9. , 9. ] ) . insert_axis( Axis ( 1 ) ) ] ;
2419 assert_eq ! ( d, aview2( & [ [ 2. ] , [ 2. ] , [ 9. ] , [ 9. ] ] ) ) ;
@@ -29,13 +24,12 @@ fn concatenating()
2924 let res = ndarray:: concatenate ( Axis ( 2 ) , & [ a. view ( ) , c. view ( ) ] ) ;
3025 assert_eq ! ( res. unwrap_err( ) . kind( ) , ErrorKind :: OutOfBounds ) ;
3126
32- let res: Result < Array2 < f64 > , _ > = ndarray:: concatenate :: < ViewRepr < & f64 > , _ , _ > ( Axis ( 0 ) , & [ ] ) ;
27+ let res: Result < Array2 < f64 > , _ > = ndarray:: concatenate :: < ViewRepr < & f64 > , _ > ( Axis ( 0 ) , & [ ] ) ;
3328 assert_eq ! ( res. unwrap_err( ) . kind( ) , ErrorKind :: Unsupported ) ;
3429}
3530
3631#[ test]
37- fn stacking ( )
38- {
32+ fn stacking ( ) {
3933 let a = arr2 ( & [ [ 2. , 2. ] , [ 3. , 3. ] ] ) ;
4034 let b = ndarray:: stack ( Axis ( 0 ) , & [ a. view ( ) , a. view ( ) ] ) . unwrap ( ) ;
4135 assert_eq ! ( b, arr3( & [ [ [ 2. , 2. ] , [ 3. , 3. ] ] , [ [ 2. , 2. ] , [ 3. , 3. ] ] ] ) ) ;
@@ -50,6 +44,6 @@ fn stacking()
5044 let res = ndarray:: stack ( Axis ( 3 ) , & [ a. view ( ) , a. view ( ) ] ) ;
5145 assert_eq ! ( res. unwrap_err( ) . kind( ) , ErrorKind :: OutOfBounds ) ;
5246
53- let res: Result < Array2 < f64 > , _ > = ndarray:: stack :: < ViewRepr < & f64 > , Ix1 , _ > ( Axis ( 0 ) , & [ ] ) ;
47+ let res: Result < Array2 < f64 > , _ > = ndarray:: stack :: < ViewRepr < & f64 > , Ix1 > ( Axis ( 0 ) , & [ ] ) ;
5448 assert_eq ! ( res. unwrap_err( ) . kind( ) , ErrorKind :: Unsupported ) ;
5549}
0 commit comments