Skip to content

Commit 2615b58

Browse files
committed
Backport PR pandas-dev#25517: TST: xfail non-writeable pytables tests with numpy 1.16x
1 parent 37da2c1 commit 2615b58

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

pandas/compat/numpy/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
_np_version_under1p13 = _nlv < LooseVersion('1.13')
1313
_np_version_under1p14 = _nlv < LooseVersion('1.14')
1414
_np_version_under1p15 = _nlv < LooseVersion('1.15')
15+
_np_version_under1p16 = _nlv < LooseVersion('1.16')
16+
_np_version_under1p17 = _nlv < LooseVersion('1.17')
1517

1618

1719
if _nlv < '1.12':
@@ -64,5 +66,7 @@ def np_array_datetime64_compat(arr, *args, **kwargs):
6466
__all__ = ['np',
6567
'_np_version_under1p13',
6668
'_np_version_under1p14',
67-
'_np_version_under1p15'
69+
'_np_version_under1p15',
70+
'_np_version_under1p16',
71+
'_np_version_under1p17'
6872
]

pandas/tests/indexes/multi/test_analytics.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55

66
from pandas.compat import lrange
7+
from pandas.compat.numpy import _np_version_under1p17
78

89
import pandas as pd
910
from pandas import Index, MultiIndex, date_range, period_range
@@ -292,9 +293,15 @@ def test_numpy_ufuncs(func):
292293
verify_integrity=False
293294
)
294295

295-
with pytest.raises(Exception):
296-
with np.errstate(all='ignore'):
297-
func(idx)
296+
if _np_version_under1p17:
297+
expected_exception = AttributeError
298+
msg = "'tuple' object has no attribute '{}'".format(func.__name__)
299+
else:
300+
expected_exception = TypeError
301+
msg = ("loop of ufunc does not support argument 0 of type tuple which"
302+
" has no callable {} method").format(func.__name__)
303+
with pytest.raises(expected_exception, match=msg):
304+
func(idx)
298305

299306

300307
@pytest.mark.parametrize('func', [

pandas/tests/io/test_pytables.py

+28-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@
3434
tables = pytest.importorskip('tables')
3535

3636

37+
# TODO:
38+
# remove when gh-24839 is fixed; this affects numpy 1.16
39+
# and pytables 3.4.4
40+
xfail_non_writeable = pytest.mark.xfail(
41+
LooseVersion(np.__version__) >= LooseVersion('1.16'),
42+
reason=('gh-25511, gh-24839. pytables needs a '
43+
'release beyong 3.4.4 to support numpy 1.16x'))
44+
45+
3746
_default_compressor = ('blosc' if LooseVersion(tables.__version__) >=
3847
LooseVersion('2.2') else 'zlib')
3948

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

887+
@xfail_non_writeable
878888
def test_put_mixed_type(self):
879889
df = tm.makeTimeDataFrame()
880890
df['obj1'] = 'foo'
@@ -1511,7 +1521,10 @@ def test_to_hdf_with_min_itemsize(self):
15111521
tm.assert_series_equal(pd.read_hdf(path, 'ss4'),
15121522
pd.concat([df['B'], df2['B']]))
15131523

1514-
@pytest.mark.parametrize("format", ['fixed', 'table'])
1524+
@pytest.mark.parametrize(
1525+
"format",
1526+
[pytest.param('fixed', marks=xfail_non_writeable),
1527+
'table'])
15151528
def test_to_hdf_errors(self, format):
15161529

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

1974+
@xfail_non_writeable
19611975
def test_append_misc(self):
19621976

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

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

2765+
@xfail_non_writeable
27502766
def test_tuple_index(self):
27512767

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

2778+
@xfail_non_writeable
27622779
@pytest.mark.filterwarnings("ignore::pandas.errors.PerformanceWarning")
27632780
def test_index_types(self):
27642781

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

2842+
@xfail_non_writeable
28252843
@pytest.mark.parametrize("compression", [
28262844
False, pytest.param(True, marks=td.skip_if_windows_python_3)
28272845
])
@@ -2852,6 +2870,7 @@ def test_frame(self, compression):
28522870
# empty
28532871
self._check_roundtrip(df[:0], tm.assert_frame_equal)
28542872

2873+
@xfail_non_writeable
28552874
def test_empty_series_frame(self):
28562875
s0 = Series()
28572876
s1 = Series(name='myseries')
@@ -2865,8 +2884,10 @@ def test_empty_series_frame(self):
28652884
self._check_roundtrip(df1, tm.assert_frame_equal)
28662885
self._check_roundtrip(df2, tm.assert_frame_equal)
28672886

2868-
def test_empty_series(self):
2869-
for dtype in [np.int64, np.float64, np.object, 'm8[ns]', 'M8[ns]']:
2887+
@xfail_non_writeable
2888+
@pytest.mark.parametrize(
2889+
'dtype', [np.int64, np.float64, np.object, 'm8[ns]', 'M8[ns]'])
2890+
def test_empty_series(self, dtype):
28702891
s = Series(dtype=dtype)
28712892
self._check_roundtrip(s, tm.assert_series_equal)
28722893

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

2971+
@xfail_non_writeable
29502972
@pytest.mark.parametrize("compression", [
29512973
False, pytest.param(True, marks=td.skip_if_windows_python_3)
29522974
])
@@ -4538,6 +4560,7 @@ def test_pytables_native2_read(self, datapath):
45384560
d1 = store['detector']
45394561
assert isinstance(d1, DataFrame)
45404562

4563+
@xfail_non_writeable
45414564
def test_legacy_table_fixed_format_read_py2(self, datapath):
45424565
# GH 24510
45434566
# legacy table with fixed format written in Python 2
@@ -4725,6 +4748,7 @@ def test_unicode_longer_encoded(self):
47254748
result = store.get('df')
47264749
tm.assert_frame_equal(result, df)
47274750

4751+
@xfail_non_writeable
47284752
def test_store_datetime_mixed(self):
47294753

47304754
df = DataFrame(
@@ -5285,6 +5309,7 @@ def test_complex_table(self):
52855309
reread = read_hdf(path, 'df')
52865310
assert_frame_equal(df, reread)
52875311

5312+
@xfail_non_writeable
52885313
def test_complex_mixed_fixed(self):
52895314
complex64 = np.array([1.0 + 1.0j, 1.0 + 1.0j,
52905315
1.0 + 1.0j, 1.0 + 1.0j], dtype=np.complex64)

0 commit comments

Comments
 (0)