Skip to content

Commit

Permalink
Backport PR pandas-dev#25517: TST: xfail non-writeable pytables tests…
Browse files Browse the repository at this point in the history
… with numpy 1.16x
  • Loading branch information
jreback committed Mar 3, 2019
1 parent 37da2c1 commit 2615b58
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
6 changes: 5 additions & 1 deletion pandas/compat/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
_np_version_under1p13 = _nlv < LooseVersion('1.13')
_np_version_under1p14 = _nlv < LooseVersion('1.14')
_np_version_under1p15 = _nlv < LooseVersion('1.15')
_np_version_under1p16 = _nlv < LooseVersion('1.16')
_np_version_under1p17 = _nlv < LooseVersion('1.17')


if _nlv < '1.12':
Expand Down Expand Up @@ -64,5 +66,7 @@ def np_array_datetime64_compat(arr, *args, **kwargs):
__all__ = ['np',
'_np_version_under1p13',
'_np_version_under1p14',
'_np_version_under1p15'
'_np_version_under1p15',
'_np_version_under1p16',
'_np_version_under1p17'
]
13 changes: 10 additions & 3 deletions pandas/tests/indexes/multi/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

from pandas.compat import lrange
from pandas.compat.numpy import _np_version_under1p17

import pandas as pd
from pandas import Index, MultiIndex, date_range, period_range
Expand Down Expand Up @@ -292,9 +293,15 @@ def test_numpy_ufuncs(func):
verify_integrity=False
)

with pytest.raises(Exception):
with np.errstate(all='ignore'):
func(idx)
if _np_version_under1p17:
expected_exception = AttributeError
msg = "'tuple' object has no attribute '{}'".format(func.__name__)
else:
expected_exception = TypeError
msg = ("loop of ufunc does not support argument 0 of type tuple which"
" has no callable {} method").format(func.__name__)
with pytest.raises(expected_exception, match=msg):
func(idx)


@pytest.mark.parametrize('func', [
Expand Down
31 changes: 28 additions & 3 deletions pandas/tests/io/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
tables = pytest.importorskip('tables')


# TODO:
# remove when gh-24839 is fixed; this affects numpy 1.16
# and pytables 3.4.4
xfail_non_writeable = pytest.mark.xfail(
LooseVersion(np.__version__) >= LooseVersion('1.16'),
reason=('gh-25511, gh-24839. pytables needs a '
'release beyong 3.4.4 to support numpy 1.16x'))


_default_compressor = ('blosc' if LooseVersion(tables.__version__) >=
LooseVersion('2.2') else 'zlib')

Expand Down Expand Up @@ -875,6 +884,7 @@ def test_put_integer(self):
df = DataFrame(np.random.randn(50, 100))
self._check_roundtrip(df, tm.assert_frame_equal)

@xfail_non_writeable
def test_put_mixed_type(self):
df = tm.makeTimeDataFrame()
df['obj1'] = 'foo'
Expand Down Expand Up @@ -1511,7 +1521,10 @@ def test_to_hdf_with_min_itemsize(self):
tm.assert_series_equal(pd.read_hdf(path, 'ss4'),
pd.concat([df['B'], df2['B']]))

@pytest.mark.parametrize("format", ['fixed', 'table'])
@pytest.mark.parametrize(
"format",
[pytest.param('fixed', marks=xfail_non_writeable),
'table'])
def test_to_hdf_errors(self, format):

data = ['\ud800foo']
Expand Down Expand Up @@ -1958,6 +1971,7 @@ def test_pass_spec_to_storer(self):
pytest.raises(TypeError, store.select,
'df', where=[('columns=A')])

@xfail_non_writeable
def test_append_misc(self):

with ensure_clean_store(self.path) as store:
Expand Down Expand Up @@ -2189,6 +2203,7 @@ def test_unimplemented_dtypes_table_columns(self):
# this fails because we have a date in the object block......
pytest.raises(TypeError, store.append, 'df_unimplemented', df)

@xfail_non_writeable
@pytest.mark.skipif(
LooseVersion(np.__version__) == LooseVersion('1.15.0'),
reason=("Skipping pytables test when numpy version is "
Expand Down Expand Up @@ -2747,6 +2762,7 @@ def test_float_index(self):
s = Series(np.random.randn(10), index=index)
self._check_roundtrip(s, tm.assert_series_equal)

@xfail_non_writeable
def test_tuple_index(self):

# GH #492
Expand All @@ -2759,6 +2775,7 @@ def test_tuple_index(self):
simplefilter("ignore", pd.errors.PerformanceWarning)
self._check_roundtrip(DF, tm.assert_frame_equal)

@xfail_non_writeable
@pytest.mark.filterwarnings("ignore::pandas.errors.PerformanceWarning")
def test_index_types(self):

Expand Down Expand Up @@ -2822,6 +2839,7 @@ def test_timeseries_preepoch(self):
except OverflowError:
pytest.skip('known failer on some windows platforms')

@xfail_non_writeable
@pytest.mark.parametrize("compression", [
False, pytest.param(True, marks=td.skip_if_windows_python_3)
])
Expand Down Expand Up @@ -2852,6 +2870,7 @@ def test_frame(self, compression):
# empty
self._check_roundtrip(df[:0], tm.assert_frame_equal)

@xfail_non_writeable
def test_empty_series_frame(self):
s0 = Series()
s1 = Series(name='myseries')
Expand All @@ -2865,8 +2884,10 @@ def test_empty_series_frame(self):
self._check_roundtrip(df1, tm.assert_frame_equal)
self._check_roundtrip(df2, tm.assert_frame_equal)

def test_empty_series(self):
for dtype in [np.int64, np.float64, np.object, 'm8[ns]', 'M8[ns]']:
@xfail_non_writeable
@pytest.mark.parametrize(
'dtype', [np.int64, np.float64, np.object, 'm8[ns]', 'M8[ns]'])
def test_empty_series(self, dtype):
s = Series(dtype=dtype)
self._check_roundtrip(s, tm.assert_series_equal)

Expand Down Expand Up @@ -2947,6 +2968,7 @@ def test_store_series_name(self):
recons = store['series']
tm.assert_series_equal(recons, series)

@xfail_non_writeable
@pytest.mark.parametrize("compression", [
False, pytest.param(True, marks=td.skip_if_windows_python_3)
])
Expand Down Expand Up @@ -4538,6 +4560,7 @@ def test_pytables_native2_read(self, datapath):
d1 = store['detector']
assert isinstance(d1, DataFrame)

@xfail_non_writeable
def test_legacy_table_fixed_format_read_py2(self, datapath):
# GH 24510
# legacy table with fixed format written in Python 2
Expand Down Expand Up @@ -4725,6 +4748,7 @@ def test_unicode_longer_encoded(self):
result = store.get('df')
tm.assert_frame_equal(result, df)

@xfail_non_writeable
def test_store_datetime_mixed(self):

df = DataFrame(
Expand Down Expand Up @@ -5285,6 +5309,7 @@ def test_complex_table(self):
reread = read_hdf(path, 'df')
assert_frame_equal(df, reread)

@xfail_non_writeable
def test_complex_mixed_fixed(self):
complex64 = np.array([1.0 + 1.0j, 1.0 + 1.0j,
1.0 + 1.0j, 1.0 + 1.0j], dtype=np.complex64)
Expand Down

0 comments on commit 2615b58

Please sign in to comment.