@@ -7,7 +7,7 @@ extern crate ndarray;
7
7
use ndarray:: { RcArray , S , Si ,
8
8
OwnedArray ,
9
9
} ;
10
- use ndarray:: { arr0, arr1, arr2,
10
+ use ndarray:: { arr0, arr1, arr2, arr3 ,
11
11
aview0,
12
12
aview1,
13
13
aview2,
@@ -683,4 +683,25 @@ fn split_at() {
683
683
let ( left, right) = b. view ( ) . axis_split_at ( 2 , 2 ) ;
684
684
assert_eq ! ( left. shape( ) , [ 3 , 4 , 2 ] ) ;
685
685
assert_eq ! ( right. shape( ) , [ 3 , 4 , 3 ] ) ;
686
+ assert_eq ! ( left, arr3( & [ [ [ 0. , 1. ] , [ 5. , 6. ] , [ 10. , 11. ] , [ 15. , 16. ] ] ,
687
+ [ [ 20. , 21. ] , [ 25. , 26. ] , [ 30. , 31. ] , [ 35. , 36. ] ] ,
688
+ [ [ 40. , 41. ] , [ 45. , 46. ] , [ 50. , 51. ] , [ 55. , 56. ] ] ] ) ) ;
689
+
690
+ // we allow for an empty right view when index == dim[axis]
691
+ let ( _, right) = b. view ( ) . axis_split_at ( 1 , 4 ) ;
692
+ assert_eq ! ( right. shape( ) , [ 3 , 0 , 5 ] ) ;
693
+ }
694
+
695
+ #[ test]
696
+ #[ should_panic]
697
+ fn deny_split_at_axis_out_of_bounds ( ) {
698
+ let a = arr2 ( & [ [ 1. , 2. ] , [ 3. , 4. ] ] ) ;
699
+ a. view ( ) . axis_split_at ( 2 , 0 ) ;
700
+ }
701
+
702
+ #[ test]
703
+ #[ should_panic]
704
+ fn deny_split_at_index_out_of_bounds ( ) {
705
+ let a = arr2 ( & [ [ 1. , 2. ] , [ 3. , 4. ] ] ) ;
706
+ a. view ( ) . axis_split_at ( 1 , 3 ) ;
686
707
}
0 commit comments