Skip to content

Add test for rdivmod on EA array (GH23287) #24047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pandas/tests/extension/base/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/extension/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]"""
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/extension/decimal/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)])
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/extension/json/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/extension/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment (skipping because its NotImplemented)


def _check_divmod_op(self, s, op, other, exc=NotImplementedError):
return super(TestArithmeticOps, self)._check_divmod_op(
s, op, other, exc=TypeError
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/extension/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/extension/test_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/extension/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/extension/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]"""
Expand Down