@@ -668,14 +668,37 @@ def test_reshape2d_pandas(pd):
668
668
for x , xnew in zip (X .T , Xnew ):
669
669
np .testing .assert_array_equal (x , xnew )
670
670
671
+
672
+ def test_reshape2d_xarray (xr ):
673
+ # separate to allow the rest of the tests to run if no xarray...
671
674
X = np .arange (30 ).reshape (10 , 3 )
672
- x = pd . DataFrame (X , columns = ["a " , "b" , "c " ])
675
+ x = xr . DataArray (X , dims = ["x " , "y " ])
673
676
Xnew = cbook ._reshape_2D (x , 'x' )
674
677
# Need to check each row because _reshape_2D returns a list of arrays:
675
678
for x , xnew in zip (X .T , Xnew ):
676
679
np .testing .assert_array_equal (x , xnew )
677
680
678
681
682
+ def test_index_of_pandas (pd ):
683
+ # separate to allow the rest of the tests to run if no pandas...
684
+ X = np .arange (30 ).reshape (10 , 3 )
685
+ x = pd .DataFrame (X , columns = ["a" , "b" , "c" ])
686
+ Idx , Xnew = cbook .index_of (x )
687
+ np .testing .assert_array_equal (X , Xnew )
688
+ IdxRef = np .arange (10 )
689
+ np .testing .assert_array_equal (Idx , IdxRef )
690
+
691
+
692
+ def test_index_of_xarray (xr ):
693
+ # separate to allow the rest of the tests to run if no xarray...
694
+ X = np .arange (30 ).reshape (10 , 3 )
695
+ x = xr .DataArray (X , dims = ["x" , "y" ])
696
+ Idx , Xnew = cbook .index_of (x )
697
+ np .testing .assert_array_equal (X , Xnew )
698
+ IdxRef = np .arange (10 )
699
+ np .testing .assert_array_equal (Idx , IdxRef )
700
+
701
+
679
702
def test_contiguous_regions ():
680
703
a , b , c = 3 , 4 , 5
681
704
# Starts and ends with True
0 commit comments