Skip to content

CLN/TEST: clean base set-op tests #42136

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
Jun 21, 2021
Merged
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
34 changes: 8 additions & 26 deletions pandas/tests/indexes/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_intersection_base(self, index):
return

# GH#10149
cases = [klass(second.values) for klass in [np.array, Series, list]]
cases = [second.to_numpy(), second.to_series(), second.to_list()]
for case in cases:
result = first.intersection(case)
assert tm.equalContents(result, second)
Expand All @@ -201,15 +201,10 @@ def test_union_base(self, index):
return

# GH#10149
cases = [klass(second.values) for klass in [np.array, Series, list]]
cases = [second.to_numpy(), second.to_series(), second.to_list()]
for case in cases:
if not isinstance(index, CategoricalIndex):
result = first.union(case)
assert tm.equalContents(result, everything), (
result,
everything,
type(case),
)
result = first.union(case)
assert tm.equalContents(result, everything)

if isinstance(index, MultiIndex):
msg = "other must be a MultiIndex or a list of tuples"
Expand All @@ -227,16 +222,10 @@ def test_difference_base(self, sort, index):
assert tm.equalContents(result, answer)

# GH#10149
cases = [klass(second.values) for klass in [np.array, Series, list]]
cases = [second.to_numpy(), second.to_series(), second.to_list()]
for case in cases:
if isinstance(index, (DatetimeIndex, TimedeltaIndex)):
assert type(result) == type(answer)
tm.assert_numpy_array_equal(
result.sort_values().asi8, answer.sort_values().asi8
)
else:
result = first.difference(case, sort)
assert tm.equalContents(result, answer)
result = first.difference(case, sort)
assert tm.equalContents(result, answer)

if isinstance(index, MultiIndex):
msg = "other must be a MultiIndex or a list of tuples"
Expand All @@ -260,16 +249,9 @@ def test_symmetric_difference(self, index):
assert tm.equalContents(result, answer)

# GH#10149
cases = [klass(second.values) for klass in [np.array, Series, list]]
cases = [second.to_numpy(), second.to_series(), second.to_list()]
for case in cases:
result = first.symmetric_difference(case)

if is_datetime64tz_dtype(first):
# second.values casts to tznaive
expected = first.union(case)
tm.assert_index_equal(result, expected)
continue

assert tm.equalContents(result, answer)

if isinstance(index, MultiIndex):
Expand Down