|
22 | 22 | from pandas.core.base import PandasObject, NoNewAttributesMixin
|
23 | 23 | from pandas.core.indexes.datetimelike import DatetimeIndexOpsMixin
|
24 | 24 | from pandas._libs.tslib import iNaT
|
| 25 | +import pandas.util.testing as tm |
25 | 26 |
|
26 | 27 |
|
27 | 28 | class CheckStringMixin(object):
|
@@ -316,16 +317,25 @@ def test_ndarray_compat_properties(self):
|
316 | 317 |
|
317 | 318 | for o in self.objs:
|
318 | 319 | # Check that we work.
|
319 |
| - for p in ['shape', 'dtype', 'flags', 'T', |
320 |
| - 'strides', 'itemsize', 'nbytes']: |
| 320 | + for p in ['shape', 'dtype', 'T', 'nbytes']: |
321 | 321 | assert getattr(o, p, None) is not None
|
322 | 322 |
|
323 |
| - assert hasattr(o, 'base') |
| 323 | + # deprecated properties |
| 324 | + for p in ['flags', 'strides', 'itemsize']: |
| 325 | + with tm.assert_produces_warning(FutureWarning): |
| 326 | + assert getattr(o, p, None) is not None |
| 327 | + |
| 328 | + # not deprecated for datetime-like indices because they are used |
| 329 | + # inside blocks |
| 330 | + if not isinstance(o, (DatetimeIndex, TimedeltaIndex, PeriodIndex)): |
| 331 | + with tm.assert_produces_warning(FutureWarning): |
| 332 | + assert hasattr(o, 'base') |
324 | 333 |
|
325 | 334 | # If we have a datetime-like dtype then needs a view to work
|
326 | 335 | # but the user is responsible for that
|
327 | 336 | try:
|
328 |
| - assert o.data is not None |
| 337 | + with tm.assert_produces_warning(FutureWarning): |
| 338 | + assert o.data is not None |
329 | 339 | except ValueError:
|
330 | 340 | pass
|
331 | 341 |
|
|
0 commit comments