@@ -701,14 +701,37 @@ def test_reshape2d_pandas(pd):
701701 for x , xnew in zip (X .T , Xnew ):
702702 np .testing .assert_array_equal (x , xnew )
703703
704+
705+ def test_reshape2d_xarray (xr ):
706+ # separate to allow the rest of the tests to run if no xarray...
704707 X = np .arange (30 ).reshape (10 , 3 )
705- x = pd . DataFrame (X , columns = ["a " , "b" , "c " ])
708+ x = xr . DataArray (X , dims = ["x " , "y " ])
706709 Xnew = cbook ._reshape_2D (x , 'x' )
707710 # Need to check each row because _reshape_2D returns a list of arrays:
708711 for x , xnew in zip (X .T , Xnew ):
709712 np .testing .assert_array_equal (x , xnew )
710713
711714
715+ def test_index_of_pandas (pd ):
716+ # separate to allow the rest of the tests to run if no pandas...
717+ X = np .arange (30 ).reshape (10 , 3 )
718+ x = pd .DataFrame (X , columns = ["a" , "b" , "c" ])
719+ Idx , Xnew = cbook .index_of (x )
720+ np .testing .assert_array_equal (X , Xnew )
721+ IdxRef = np .arange (10 )
722+ np .testing .assert_array_equal (Idx , IdxRef )
723+
724+
725+ def test_index_of_xarray (xr ):
726+ # separate to allow the rest of the tests to run if no xarray...
727+ X = np .arange (30 ).reshape (10 , 3 )
728+ x = xr .DataArray (X , dims = ["x" , "y" ])
729+ Idx , Xnew = cbook .index_of (x )
730+ np .testing .assert_array_equal (X , Xnew )
731+ IdxRef = np .arange (10 )
732+ np .testing .assert_array_equal (Idx , IdxRef )
733+
734+
712735def test_contiguous_regions ():
713736 a , b , c = 3 , 4 , 5
714737 # Starts and ends with True
0 commit comments