diff --git a/pandas/tests/extension/base/ops.py b/pandas/tests/extension/base/ops.py index cd5e55d9871b2..2ac68c52d53c7 100644 --- a/pandas/tests/extension/base/ops.py +++ b/pandas/tests/extension/base/ops.py @@ -91,10 +91,16 @@ def test_divmod(self, data): self._check_divmod_op(s, divmod, 1, exc=self.divmod_exc) self._check_divmod_op(1, ops.rdivmod, s, exc=self.divmod_exc) - def test_divmod_series_array(self, data): + def test_divmod_series_array(self, data, data_for_twos): s = pd.Series(data) self._check_divmod_op(s, divmod, data) + other = data_for_twos + self._check_divmod_op(other, ops.rdivmod, s) + + other = pd.Series(other) + self._check_divmod_op(other, ops.rdivmod, s) + def test_add_series_with_extension_array(self, data): s = pd.Series(data) result = s + data diff --git a/pandas/tests/extension/conftest.py b/pandas/tests/extension/conftest.py index 3cc2d313b09f5..b6e839f250e4e 100644 --- a/pandas/tests/extension/conftest.py +++ b/pandas/tests/extension/conftest.py @@ -21,6 +21,12 @@ def data(): raise NotImplementedError +@pytest.fixture +def data_for_twos(): + """Length-100 array in which all the elements are two.""" + raise NotImplementedError + + @pytest.fixture def data_missing(): """Length-2 array with [NA, Valid]""" diff --git a/pandas/tests/extension/decimal/test_decimal.py b/pandas/tests/extension/decimal/test_decimal.py index 6281c5360cd03..686bd898f5171 100644 --- a/pandas/tests/extension/decimal/test_decimal.py +++ b/pandas/tests/extension/decimal/test_decimal.py @@ -23,6 +23,11 @@ def data(): return DecimalArray(make_data()) +@pytest.fixture +def data_for_twos(): + return DecimalArray([decimal.Decimal(2) for _ in range(100)]) + + @pytest.fixture def data_missing(): return DecimalArray([decimal.Decimal('NaN'), decimal.Decimal(1)]) diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index 9ee131950f19c..8c7e99b7d0cc5 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -290,6 +290,11 @@ def test_add_series_with_extension_array(self, data): with pytest.raises(TypeError, match="unsupported"): ser + data + def test_divmod_series_array(self): + # GH 23287 + # skipping because it is not implemented + pass + def _check_divmod_op(self, s, op, other, exc=NotImplementedError): return super(TestArithmeticOps, self)._check_divmod_op( s, op, other, exc=TypeError diff --git a/pandas/tests/extension/test_categorical.py b/pandas/tests/extension/test_categorical.py index ac52d8f15b8ce..9871d0d8f96f5 100644 --- a/pandas/tests/extension/test_categorical.py +++ b/pandas/tests/extension/test_categorical.py @@ -214,6 +214,11 @@ def test_add_series_with_extension_array(self, data): with pytest.raises(TypeError, match="cannot perform"): ser + data + def test_divmod_series_array(self): + # GH 23287 + # skipping because it is not implemented + pass + def _check_divmod_op(self, s, op, other, exc=NotImplementedError): return super(TestArithmeticOps, self)._check_divmod_op( s, op, other, exc=TypeError diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index 00ad35bf6a924..e3fdd0db3e8b4 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -147,6 +147,11 @@ def test_arith_series_with_array(self, data, all_arithmetic_operators): def test_error(self, data, all_arithmetic_operators): pass + def test_divmod_series_array(self): + # GH 23287 + # skipping because it is not implemented + pass + @pytest.mark.xfail(reason="different implementation", strict=False) def test_direct_arith_with_series_returns_not_implemented(self, data): # Right now, we have trouble with this. Returning NotImplemented diff --git a/pandas/tests/extension/test_integer.py b/pandas/tests/extension/test_integer.py index aadf9f2f12b68..a8dcabbb824d5 100644 --- a/pandas/tests/extension/test_integer.py +++ b/pandas/tests/extension/test_integer.py @@ -42,6 +42,11 @@ def data(dtype): return integer_array(make_data(), dtype=dtype) +@pytest.fixture +def data_for_twos(dtype): + return integer_array(np.ones(100) * 2, dtype=dtype) + + @pytest.fixture def data_missing(dtype): return integer_array([np.nan, 1], dtype=dtype) diff --git a/pandas/tests/extension/test_period.py b/pandas/tests/extension/test_period.py index 813efcb5678d3..fb3c4e87abcf5 100644 --- a/pandas/tests/extension/test_period.py +++ b/pandas/tests/extension/test_period.py @@ -20,6 +20,11 @@ def data(dtype): return PeriodArray(np.arange(1970, 2070), freq=dtype.freq) +@pytest.fixture +def data_for_twos(dtype): + return PeriodArray(np.ones(100) * 2, freq=dtype.freq) + + @pytest.fixture def data_for_sorting(dtype): return PeriodArray([2018, 2019, 2017], freq=dtype.freq) diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 146dea2b65d83..3e1186f59478f 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -34,6 +34,11 @@ def data(request): return res +@pytest.fixture +def data_for_twos(request): + return SparseArray(np.ones(100) * 2) + + @pytest.fixture(params=[0, np.nan]) def data_missing(request): """Length 2 array with [NA, Valid]"""