sorted_index = self.take(_as)
return sorted_index, _as
else:
- sorted_values = np.sort(self._ndarray_values)
+ # NB: using asi8 instead of _ndarray_values matters in numpy 1.18
+ # because the treatment of NaT has been changed to put NaT last
+ # instead of first.
+ sorted_values = np.sort(self.asi8)
attribs = self._get_attributes_dict()
freq = attribs["freq"]
Float64Index,
Index,
Int64Index,
+ PeriodIndex,
TimedeltaIndex,
UInt64Index,
_np_version_under1p17,
+ _np_version_under1p18,
)
from pandas.core.indexes.datetimelike import DatetimeIndexOpsMixin
from pandas.util import testing as tm
idx = indices
if isinstance(idx, (DatetimeIndex, TimedeltaIndex)):
- # ok under numpy >= 1.17
- if not _np_version_under1p17 and func in [np.isfinite]:
+ if not _np_version_under1p18 and func in [np.isfinite, np.isinf, np.isnan]:
+ # numpy 1.18(dev) changed isinf and isnan to not raise on dt64/tfd64
+ result = func(idx)
+ assert isinstance(result, np.ndarray)
+
+ elif not _np_version_under1p17 and func in [np.isfinite]:
+ # ok under numpy >= 1.17
# Results in bool array
result = func(idx)
assert isinstance(result, np.ndarray)
- assert not isinstance(result, Index)
else:
# raise TypeError or ValueError (PeriodIndex)
with pytest.raises(Exception):
func(idx)
- elif isinstance(idx, DatetimeIndexOpsMixin):
+ elif isinstance(idx, PeriodIndex):
# raise TypeError or ValueError (PeriodIndex)
with pytest.raises(Exception):
func(idx)