Skip to content

Commit

Permalink
CLN/TEST: clean setops tests (pandas-dev#42136)
Browse files Browse the repository at this point in the history
  • Loading branch information
topper-123 authored and JulianWgs committed Jul 3, 2021
1 parent ed9466f commit 270b510
Showing 1 changed file with 8 additions and 26 deletions.
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

0 comments on commit 270b510

Please sign in to comment.