@@ -241,35 +241,40 @@ def test_view(self):
241241 def test_dtype (self ):
242242 assert self .index .dtype == np .int64
243243
244- def test_has_called_data (self ):
245- # Calling RangeIndex._data caches a array of the same length.
246- # This tests whether RangeIndex._data has been called by doing methods
244+ def test_cached_data (self ):
245+ # Calling RangeIndex._data caches an int64 array of the same length at
246+ # self._cached_data. This tests whether _cached_data has been set.
247247 idx = RangeIndex (0 , 100 , 10 )
248- assert idx ._has_called_data is False
248+
249+ assert idx ._cached_data is None
249250
250251 repr (idx )
251- assert idx ._has_called_data is False
252+ assert idx ._cached_data is None
252253
253254 str (idx )
254- assert idx ._has_called_data is False
255+ assert idx ._cached_data is None
255256
256257 idx .get_loc (20 )
257- assert idx ._has_called_data is False
258+ assert idx ._cached_data is None
258259
259260 df = pd .DataFrame ({'a' : range (10 )}, index = idx )
260261
261262 df .loc [50 ]
262- assert idx ._has_called_data is False
263+ assert idx ._cached_data is None
263264
264265 with pytest .raises (KeyError ):
265266 df .loc [51 ]
266- assert idx ._has_called_data is False
267+ assert idx ._cached_data is None
267268
268269 df .loc [10 :50 ]
269- assert idx ._has_called_data is False
270+ assert idx ._cached_data is None
270271
271272 df .iloc [5 :10 ]
272- assert idx ._has_called_data is False
273+ assert idx ._cached_data is None
274+
275+ # actually calling data._data
276+ assert isinstance (idx ._data , np .ndarray )
277+ assert isinstance (idx ._cached_data , np .ndarray )
273278
274279 def test_is_monotonic (self ):
275280 assert self .index .is_monotonic is True
0 commit comments