Skip to content

REF: de-duplicate test_combine_add #54414

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 1 commit into from
Aug 4, 2023
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
23 changes: 17 additions & 6 deletions pandas/tests/extension/base/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,24 @@ def test_combine_add(self, data_repeated):
orig_data1, orig_data2 = data_repeated(2)
s1 = pd.Series(orig_data1)
s2 = pd.Series(orig_data2)
result = s1.combine(s2, lambda x1, x2: x1 + x2)
with np.errstate(over="ignore"):
expected = pd.Series(
orig_data1._from_sequence(
[a + b for (a, b) in zip(list(orig_data1), list(orig_data2))]

# Check if the operation is supported pointwise for our scalars. If not,
# we will expect Series.combine to raise as well.
try:
with np.errstate(over="ignore"):
expected = pd.Series(
orig_data1._from_sequence(
[a + b for (a, b) in zip(list(orig_data1), list(orig_data2))]
)
)
)
except TypeError:
# If the operation is not supported pointwise for our scalars,
# then Series.combine should also raise
with pytest.raises(TypeError):
s1.combine(s2, lambda x1, x2: x1 + x2)
return

result = s1.combine(s2, lambda x1, x2: x1 + x2)
tm.assert_series_equal(result, expected)

val = s1.iloc[0]
Expand Down
4 changes: 0 additions & 4 deletions pandas/tests/extension/json/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,6 @@ def test_sort_values_missing(
def test_combine_le(self, data_repeated):
super().test_combine_le(data_repeated)

@pytest.mark.xfail(reason="combine for JSONArray not supported")
def test_combine_add(self, data_repeated):
super().test_combine_add(data_repeated)

@pytest.mark.xfail(
reason="combine for JSONArray not supported - "
"may pass depending on random data",
Expand Down
13 changes: 0 additions & 13 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,19 +821,6 @@ def test_argreduce_series(

_combine_le_expected_dtype = "bool[pyarrow]"

def test_combine_add(self, data_repeated, request):
pa_dtype = next(data_repeated(1)).dtype.pyarrow_dtype
if pa.types.is_temporal(pa_dtype) and not pa.types.is_duration(pa_dtype):
# analogous to datetime64, these cannot be added
orig_data1, orig_data2 = data_repeated(2)
s1 = pd.Series(orig_data1)
s2 = pd.Series(orig_data2)
with pytest.raises(TypeError):
s1.combine(s2, lambda x1, x2: x1 + x2)

else:
super().test_combine_add(data_repeated)


class TestBaseArithmeticOps(base.BaseArithmeticOpsTests):
divmod_exc = NotImplementedError
Expand Down
4 changes: 0 additions & 4 deletions pandas/tests/extension/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ class TestIndex(base.BaseIndexTests):


class TestMethods(BaseDatetimeTests, base.BaseMethodsTests):
def test_combine_add(self, data_repeated):
# Timestamp.__add__(Timestamp) not defined
pass

@pytest.mark.parametrize("na_action", [None, "ignore"])
def test_map(self, data, na_action):
result = data.map(lambda x: x, na_action=na_action)
Expand Down
4 changes: 0 additions & 4 deletions pandas/tests/extension/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna):


class TestMethods(BaseInterval, base.BaseMethodsTests):
@pytest.mark.xfail(reason="addition is not defined for intervals")
def test_combine_add(self, data_repeated):
super().test_combine_add(data_repeated)

@pytest.mark.xfail(
reason="Raises with incorrect message bc it disallows *all* listlikes "
"instead of just wrong-length listlikes"
Expand Down
4 changes: 0 additions & 4 deletions pandas/tests/extension/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ class TestIndex(base.BaseIndexTests):


class TestMethods(BasePeriodTests, base.BaseMethodsTests):
def test_combine_add(self, data_repeated):
# Period + Period is not defined.
pass

@pytest.mark.parametrize("periods", [1, -2])
def test_diff(self, data, periods):
if is_platform_windows() and np_version_gte1p24:
Expand Down