Skip to content

Commit

Permalink
COMPAT: compat with released numpy 1.11 for IndexError -> TypeError
Browse files Browse the repository at this point in the history
was a revert of # numpy/numpy#6271

closes #12729
closes #12736
  • Loading branch information
jreback committed Apr 4, 2016
1 parent 75a9fb9 commit be5ccea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
20 changes: 9 additions & 11 deletions pandas/compat/numpy_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
from distutils.version import LooseVersion
from pandas.compat import string_types, string_and_binary_types

# TODO: HACK for NumPy 1.5.1 to suppress warnings
# is this necessary?
try:
np.seterr(all='ignore')
except Exception: # pragma: no cover
pass
# turn off all numpy warnings
np.seterr(all='ignore')

# numpy versioning
_np_version = np.version.short_version
_np_version_under1p8 = LooseVersion(_np_version) < '1.8'
_np_version_under1p9 = LooseVersion(_np_version) < '1.9'
_np_version_under1p10 = LooseVersion(_np_version) < '1.10'
_np_version_under1p11 = LooseVersion(_np_version) < '1.11'
_nlv = LooseVersion(_np_version)
_np_version_under1p8 = _nlv < '1.8'
_np_version_under1p9 = _nlv < '1.9'
_np_version_under1p10 = _nlv < '1.10'
_np_version_under1p11 = _nlv < '1.11'
_np_version_under1p12 = _nlv < '1.12'

if LooseVersion(_np_version) < '1.7.0':
raise ImportError('this version of pandas is incompatible with '
Expand Down Expand Up @@ -67,9 +65,9 @@ def np_array_datetime64_compat(arr, *args, **kwargs):
return np.array(arr, *args, **kwargs)

__all__ = ['np',
'_np_version',
'_np_version_under1p8',
'_np_version_under1p9',
'_np_version_under1p10',
'_np_version_under1p11',
'_np_version_under1p12',
]
12 changes: 7 additions & 5 deletions pandas/tseries/tests/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pandas.compat.numpy_compat import np_datetime64_compat

from pandas import (Series, DataFrame,
_np_version_under1p9, _np_version_under1p11)
_np_version_under1p9, _np_version_under1p12)
from pandas import tslib
from pandas.util.testing import (assert_series_equal, assert_almost_equal,
assertRaisesRegexp)
Expand Down Expand Up @@ -2607,8 +2607,9 @@ def test_range_slice_day(self):
didx = DatetimeIndex(start='2013/01/01', freq='D', periods=400)
pidx = PeriodIndex(start='2013/01/01', freq='D', periods=400)

# changed to TypeError in 1.11
exc = IndexError if _np_version_under1p11 else TypeError
# changed to TypeError in 1.12
# https://github.com/numpy/numpy/pull/6271
exc = IndexError if _np_version_under1p12 else TypeError

for idx in [didx, pidx]:
# slices against index should raise IndexError
Expand Down Expand Up @@ -2664,8 +2665,9 @@ def test_range_slice_seconds(self):
periods=4000)
pidx = PeriodIndex(start='2013/01/01 09:00:00', freq='S', periods=4000)

# changed to TypeError in 1.11
exc = IndexError if _np_version_under1p11 else TypeError
# changed to TypeError in 1.12
# https://github.com/numpy/numpy/pull/6271
exc = IndexError if _np_version_under1p12 else TypeError

for idx in [didx, pidx]:
# slices against index should raise IndexError
Expand Down

0 comments on commit be5ccea

Please sign in to comment.