@@ -680,14 +680,37 @@ def test_reshape2d_pandas(pd):
680680 for x , xnew in zip (X .T , Xnew ):
681681 np .testing .assert_array_equal (x , xnew )
682682
683+
684+ def test_reshape2d_xarray (xr ):
685+ # separate to allow the rest of the tests to run if no xarray...
683686 X = np .arange (30 ).reshape (10 , 3 )
684- x = pd . DataFrame (X , columns = ["a " , "b" , "c " ])
687+ x = xr . DataArray (X , dims = ["x " , "y " ])
685688 Xnew = cbook ._reshape_2D (x , 'x' )
686689 # Need to check each row because _reshape_2D returns a list of arrays:
687690 for x , xnew in zip (X .T , Xnew ):
688691 np .testing .assert_array_equal (x , xnew )
689692
690693
694+ def test_index_of_pandas (pd ):
695+ # separate to allow the rest of the tests to run if no pandas...
696+ X = np .arange (30 ).reshape (10 , 3 )
697+ x = pd .DataFrame (X , columns = ["a" , "b" , "c" ])
698+ Idx , Xnew = cbook .index_of (x )
699+ np .testing .assert_array_equal (X , Xnew )
700+ IdxRef = np .arange (10 )
701+ np .testing .assert_array_equal (Idx , IdxRef )
702+
703+
704+ def test_index_of_xarray (xr ):
705+ # separate to allow the rest of the tests to run if no xarray...
706+ X = np .arange (30 ).reshape (10 , 3 )
707+ x = xr .DataArray (X , dims = ["x" , "y" ])
708+ Idx , Xnew = cbook .index_of (x )
709+ np .testing .assert_array_equal (X , Xnew )
710+ IdxRef = np .arange (10 )
711+ np .testing .assert_array_equal (Idx , IdxRef )
712+
713+
691714def test_contiguous_regions ():
692715 a , b , c = 3 , 4 , 5
693716 # Starts and ends with True
0 commit comments