Skip to content

Commit a70eb0f

Browse files
makbigcjreback
authored andcommitted
Add test for rdivmod on EA array (GH23287) (#24047)
1 parent 9ab270f commit a70eb0f

File tree

9 files changed

+48
-1
lines changed

9 files changed

+48
-1
lines changed

pandas/tests/extension/base/ops.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,16 @@ def test_divmod(self, data):
9191
self._check_divmod_op(s, divmod, 1, exc=self.divmod_exc)
9292
self._check_divmod_op(1, ops.rdivmod, s, exc=self.divmod_exc)
9393

94-
def test_divmod_series_array(self, data):
94+
def test_divmod_series_array(self, data, data_for_twos):
9595
s = pd.Series(data)
9696
self._check_divmod_op(s, divmod, data)
9797

98+
other = data_for_twos
99+
self._check_divmod_op(other, ops.rdivmod, s)
100+
101+
other = pd.Series(other)
102+
self._check_divmod_op(other, ops.rdivmod, s)
103+
98104
def test_add_series_with_extension_array(self, data):
99105
s = pd.Series(data)
100106
result = s + data

pandas/tests/extension/conftest.py

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ def data():
2121
raise NotImplementedError
2222

2323

24+
@pytest.fixture
25+
def data_for_twos():
26+
"""Length-100 array in which all the elements are two."""
27+
raise NotImplementedError
28+
29+
2430
@pytest.fixture
2531
def data_missing():
2632
"""Length-2 array with [NA, Valid]"""

pandas/tests/extension/decimal/test_decimal.py

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def data():
2323
return DecimalArray(make_data())
2424

2525

26+
@pytest.fixture
27+
def data_for_twos():
28+
return DecimalArray([decimal.Decimal(2) for _ in range(100)])
29+
30+
2631
@pytest.fixture
2732
def data_missing():
2833
return DecimalArray([decimal.Decimal('NaN'), decimal.Decimal(1)])

pandas/tests/extension/json/test_json.py

+5
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ def test_add_series_with_extension_array(self, data):
290290
with pytest.raises(TypeError, match="unsupported"):
291291
ser + data
292292

293+
def test_divmod_series_array(self):
294+
# GH 23287
295+
# skipping because it is not implemented
296+
pass
297+
293298
def _check_divmod_op(self, s, op, other, exc=NotImplementedError):
294299
return super(TestArithmeticOps, self)._check_divmod_op(
295300
s, op, other, exc=TypeError

pandas/tests/extension/test_categorical.py

+5
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ def test_add_series_with_extension_array(self, data):
214214
with pytest.raises(TypeError, match="cannot perform"):
215215
ser + data
216216

217+
def test_divmod_series_array(self):
218+
# GH 23287
219+
# skipping because it is not implemented
220+
pass
221+
217222
def _check_divmod_op(self, s, op, other, exc=NotImplementedError):
218223
return super(TestArithmeticOps, self)._check_divmod_op(
219224
s, op, other, exc=TypeError

pandas/tests/extension/test_datetime.py

+5
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ def test_arith_series_with_array(self, data, all_arithmetic_operators):
147147
def test_error(self, data, all_arithmetic_operators):
148148
pass
149149

150+
def test_divmod_series_array(self):
151+
# GH 23287
152+
# skipping because it is not implemented
153+
pass
154+
150155
@pytest.mark.xfail(reason="different implementation", strict=False)
151156
def test_direct_arith_with_series_returns_not_implemented(self, data):
152157
# Right now, we have trouble with this. Returning NotImplemented

pandas/tests/extension/test_integer.py

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ def data(dtype):
4242
return integer_array(make_data(), dtype=dtype)
4343

4444

45+
@pytest.fixture
46+
def data_for_twos(dtype):
47+
return integer_array(np.ones(100) * 2, dtype=dtype)
48+
49+
4550
@pytest.fixture
4651
def data_missing(dtype):
4752
return integer_array([np.nan, 1], dtype=dtype)

pandas/tests/extension/test_period.py

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ def data(dtype):
2020
return PeriodArray(np.arange(1970, 2070), freq=dtype.freq)
2121

2222

23+
@pytest.fixture
24+
def data_for_twos(dtype):
25+
return PeriodArray(np.ones(100) * 2, freq=dtype.freq)
26+
27+
2328
@pytest.fixture
2429
def data_for_sorting(dtype):
2530
return PeriodArray([2018, 2019, 2017], freq=dtype.freq)

pandas/tests/extension/test_sparse.py

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ def data(request):
3434
return res
3535

3636

37+
@pytest.fixture
38+
def data_for_twos(request):
39+
return SparseArray(np.ones(100) * 2)
40+
41+
3742
@pytest.fixture(params=[0, np.nan])
3843
def data_missing(request):
3944
"""Length 2 array with [NA, Valid]"""

0 commit comments

Comments
 (0)