Skip to content

Commit 9122bb6

Browse files
committed
implement skips
1 parent 38e7413 commit 9122bb6

File tree

2 files changed

+81
-6
lines changed

2 files changed

+81
-6
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import pytest
2+
3+
# A set of Base EA tests that are know to not work for
4+
# the object-dtype PandasArray holding nested data.
5+
skips = {
6+
'BaseCastingTests.test_astype_str',
7+
'BaseConstructorsTests.test_array_from_scalars',
8+
# tuple isn't instance of np.object
9+
'BaseGetitemTests.test_getitem_scalar',
10+
# Can't pass tuples to _from_sequence
11+
'BaseGetitemTests.test_take_series',
12+
# np.array shape inference
13+
'BaseInterfaceTests.test_array_interface',
14+
# Can't construct expected.
15+
'BaseMethodsTests.test_unique',
16+
'BaseMethodsTests.test_combine_add',
17+
'BaseMethodsTests.test_shift_fill_value',
18+
'BaseMethodsTests.test_where_series',
19+
'BaseMethodsTests.test_repeat',
20+
# Can't hash ndarray[tuple]
21+
'BaseMethodsTests.test_hash_pandas_object_works',
22+
# Can't construct expected.
23+
'BaseReshapingTests.test_merge',
24+
'BaseReshapingTests.test_merge_on_extension_array',
25+
'BaseReshapingTests.test_merge_on_extension_array_duplicates',
26+
27+
# ndarray setting
28+
'BaseSetitemTests.test_setitem_scalar_series',
29+
'BaseSetitemTests.test_setitem_sequence',
30+
'BaseSetitemTests.test_setitem_sequence_mismatched_length_raises',
31+
'BaseSetitemTests.test_setitem_sequence_broadcasts',
32+
'BaseSetitemTests.test_setitem_sequence_broadcasts',
33+
'BaseSetitemTests.test_setitem_loc_scalar_mixed',
34+
'BaseSetitemTests.test_setitem_iloc_scalar_mixed',
35+
'BaseSetitemTests.test_setitem_loc_scalar_multiple_homogoneous',
36+
'BaseSetitemTests.test_setitem_iloc_scalar_multiple_homogoneous',
37+
'BaseSetitemTests.test_setitem_mask_broadcast',
38+
'BaseSetitemTests.test_setitem_scalar_key_sequence_raise',
39+
40+
'BaseParsingTests.test_EA_types',
41+
}
42+
43+
44+
def pytest_collection_modifyitems(config, items):
45+
skip = pytest.mark.skip(reason="Skipping this because ...")
46+
for item in items:
47+
# TODO: See if pytest has a better way to resolve the *value*
48+
# supplied to a fixture. Right now .keywords gets things
49+
# like 'object' or 'data-object'.
50+
parts = item.name.split("[")
51+
if (len(parts) > 1 and 'object' in item.name.split('[')[1]
52+
and item.obj.__qualname__ in skips):
53+
item.add_marker(skip)

pandas/tests/extension/numpy_/test_numpy.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
from pandas.core.arrays.numpy_ import PandasArray, PandasDtype
77
import pandas.util.testing as tm
88

9-
from . import base
9+
from .. import base
1010

1111

12-
@pytest.fixture
13-
def dtype():
14-
return PandasDtype(np.dtype('float'))
12+
@pytest.fixture(params=['float', 'object'])
13+
def dtype(request):
14+
return PandasDtype(np.dtype(request.param))
1515

1616

1717
@pytest.fixture
@@ -38,6 +38,8 @@ def allow_in_pandas(monkeypatch):
3838

3939
@pytest.fixture
4040
def data(allow_in_pandas, dtype):
41+
if dtype.numpy_dtype == 'object':
42+
return pd.Series([(i,) for i in range(100)]).array
4143
return PandasArray(np.arange(1, 101, dtype=dtype._dtype))
4244

4345

@@ -150,6 +152,19 @@ class TestArithmetics(BaseNumPyTests, base.BaseArithmeticOpsTests):
150152
frame_scalar_exc = None
151153
series_array_exc = None
152154

155+
def _check_op(self, s, op, other, op_name, exc=NotImplementedError):
156+
if s.dtype == 'object':
157+
raise pytest.skip("Skipping for object dtype.")
158+
super(TestArithmetics, self)._check_op(s, op, other, op_name, exc)
159+
160+
def _check_divmod_op(self, s, op, other, exc=Exception):
161+
if isinstance(s, pd.Series) and s.dtype == 'object':
162+
raise pytest.skip("Skipping for object dtype.")
163+
elif isinstance(other, pd.Series) and other.dtype == 'object':
164+
raise pytest.skip("Skipping for object dtype.")
165+
166+
super(TestArithmetics, self)._check_divmod_op(s, op, other, exc)
167+
153168
def test_divmod_series_array(self, data):
154169
s = pd.Series(data)
155170
self._check_divmod_op(s, divmod, data, exc=None)
@@ -186,17 +201,24 @@ class TestPrinting(BaseNumPyTests, base.BasePrintingTests):
186201
class TestNumericReduce(BaseNumPyTests, base.BaseNumericReduceTests):
187202

188203
def check_reduce(self, s, op_name, skipna):
204+
if s.dtype == 'object':
205+
raise pytest.skip("Skipping for object dtype.")
189206
result = getattr(s, op_name)(skipna=skipna)
190207
# avoid coercing int -> float. Just cast to the actual numpy type.
191208
expected = getattr(s.astype(s.dtype._dtype), op_name)(skipna=skipna)
192209
tm.assert_almost_equal(result, expected)
193210

194211

195212
class TestBooleanReduce(BaseNumPyTests, base.BaseBooleanReduceTests):
196-
pass
213+
214+
def check_reduce(self, s, op_name, skipna):
215+
if s.dtype == 'object':
216+
raise pytest.skip("Skipping for object dtype.")
217+
218+
super(TestBooleanReduce, self).check_reduce(s, op_name, skipna)
197219

198220

199-
class TestMising(BaseNumPyTests, base.BaseMissingTests):
221+
class TestMissing(BaseNumPyTests, base.BaseMissingTests):
200222
pass
201223

202224

0 commit comments

Comments
 (0)