Skip to content

Commit

Permalink
TST: Add test for union with duplicates (pandas-dev#40967)
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl authored Apr 20, 2021
1 parent 95d2667 commit 8b1430d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pandas/tests/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -2418,10 +2418,16 @@ def test_diff_low_precision_int(self, dtype):
tm.assert_numpy_array_equal(result, expected)


def test_union_with_duplicates():
@pytest.mark.parametrize("op", [np.array, pd.array])
def test_union_with_duplicates(op):
# GH#36289
lvals = np.array([3, 1, 3, 4])
rvals = np.array([2, 3, 1, 1])
result = algos.union_with_duplicates(lvals, rvals)
expected = np.array([3, 3, 1, 1, 4, 2])
tm.assert_numpy_array_equal(result, expected)
lvals = op([3, 1, 3, 4])
rvals = op([2, 3, 1, 1])
expected = op([3, 3, 1, 1, 4, 2])
if isinstance(expected, np.ndarray):
result = algos.union_with_duplicates(lvals, rvals)
tm.assert_numpy_array_equal(result, expected)
else:
with tm.assert_produces_warning(RuntimeWarning):
result = algos.union_with_duplicates(lvals, rvals)
tm.assert_extension_array_equal(result, expected)

0 comments on commit 8b1430d

Please sign in to comment.