@@ -668,14 +668,37 @@ def test_reshape2d_pandas(pd):
668668 for x , xnew in zip (X .T , Xnew ):
669669 np .testing .assert_array_equal (x , xnew )
670670
671+
672+ def test_reshape2d_xarray (xr ):
673+ # separate to allow the rest of the tests to run if no xarray...
671674 X = np .arange (30 ).reshape (10 , 3 )
672- x = pd . DataFrame (X , columns = ["a " , "b" , "c " ])
675+ x = xr . DataArray (X , dims = ["x " , "y " ])
673676 Xnew = cbook ._reshape_2D (x , 'x' )
674677 # Need to check each row because _reshape_2D returns a list of arrays:
675678 for x , xnew in zip (X .T , Xnew ):
676679 np .testing .assert_array_equal (x , xnew )
677680
678681
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+
679702def test_contiguous_regions ():
680703 a , b , c = 3 , 4 , 5
681704 # Starts and ends with True
0 commit comments