@@ -177,12 +177,17 @@ def test_constructor_ndarray_like(self):
177177 # it should be possible to convert any object that satisfies the numpy
178178 # ndarray interface directly into an Index
179179 class ArrayLike (object ):
180+ def __init__ (self , array ):
181+ self .array = array
180182 def __array__ (self , dtype = None ):
181- return np . arange ( 5 )
183+ return self . array
182184
183- expected = pd .Index (np .arange (5 ))
184- result = pd .Index (ArrayLike ())
185- self .assertTrue (result .equals (expected ))
185+ for array in [np .arange (5 ),
186+ np .array (['a' , 'b' , 'c' ]),
187+ pd .date_range ('2000-01-01' , periods = 3 ).values ]:
188+ expected = pd .Index (array )
189+ result = pd .Index (ArrayLike (array ))
190+ self .assertTrue (result .equals (expected ))
186191
187192 def test_index_ctor_infer_periodindex (self ):
188193 from pandas import period_range , PeriodIndex
@@ -447,7 +452,7 @@ def test_intersection(self):
447452 assertRaisesRegexp (TypeError , "iterable" , first .intersection , 0.5 )
448453
449454 idx1 = Index ([1 , 2 , 3 , 4 , 5 ], name = 'idx' )
450- # if target has the same name, it is preserved
455+ # if target has the same name, it is preserved
451456 idx2 = Index ([3 , 4 , 5 , 6 , 7 ], name = 'idx' )
452457 expected2 = Index ([3 , 4 , 5 ], name = 'idx' )
453458 result2 = idx1 .intersection (idx2 )
0 commit comments