From 3e3c9019a11fbdf9e61fc36ca216fd128c25ae04 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Sat, 2 Mar 2019 16:08:08 -0500 Subject: [PATCH] TST: xfail non-writeable pytables tests with numpy 1.16x (#25517) --- pandas/compat/numpy/__init__.py | 4 ++- pandas/tests/indexes/multi/test_analytics.py | 4 +-- pandas/tests/io/test_pytables.py | 31 ++++++++++++++++++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/pandas/compat/numpy/__init__.py b/pandas/compat/numpy/__init__.py index bc9af01a97467..6e9f768d8bd68 100644 --- a/pandas/compat/numpy/__init__.py +++ b/pandas/compat/numpy/__init__.py @@ -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': @@ -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' ] diff --git a/pandas/tests/indexes/multi/test_analytics.py b/pandas/tests/indexes/multi/test_analytics.py index 27a5ba9e5434a..d5a6e9acaa5f3 100644 --- a/pandas/tests/indexes/multi/test_analytics.py +++ b/pandas/tests/indexes/multi/test_analytics.py @@ -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 @@ -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: diff --git a/pandas/tests/io/test_pytables.py b/pandas/tests/io/test_pytables.py index b464903d8b4e0..69ff32d1b728b 100644 --- a/pandas/tests/io/test_pytables.py +++ b/pandas/tests/io/test_pytables.py @@ -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') @@ -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' @@ -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'] @@ -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: @@ -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 " @@ -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 @@ -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): @@ -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) ]) @@ -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') @@ -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) @@ -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) ]) @@ -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 @@ -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( @@ -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)