Skip to content

Commit

Permalink
TST: xfail non-writeable pytables tests with numpy 1.16x (#25517)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback authored Mar 2, 2019
1 parent ae4db86 commit 3e3c901
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
4 changes: 3 additions & 1 deletion pandas/compat/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
_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 @@ -66,5 +67,6 @@ def np_array_datetime64_compat(arr, *args, **kwargs):
'_np_version_under1p13',
'_np_version_under1p14',
'_np_version_under1p15',
'_np_version_under1p16'
'_np_version_under1p16',
'_np_version_under1p17'
]
4 changes: 2 additions & 2 deletions pandas/tests/indexes/multi/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from pandas.compat import PY2, lrange
from pandas.compat.numpy import _np_version_under1p16
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 @@ -287,7 +287,7 @@ def test_numpy_ufuncs(idx, func):
# test ufuncs of numpy. see:
# http://docs.scipy.org/doc/numpy/reference/ufuncs.html

if _np_version_under1p16:
if _np_version_under1p17:
expected_exception = AttributeError
msg = "'tuple' object has no attribute '{}'".format(func.__name__)
else:
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 @@ -862,6 +871,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 @@ -1438,7 +1448,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 @@ -1815,6 +1828,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 @@ -2006,6 +2020,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 @@ -2245,6 +2260,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 @@ -2257,6 +2273,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 @@ -2320,6 +2337,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 @@ -2350,6 +2368,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 @@ -2363,8 +2382,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 @@ -2445,6 +2466,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 @@ -3954,6 +3976,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 @@ -4117,6 +4140,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 @@ -4677,6 +4701,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 3e3c901

Please sign in to comment.