Skip to content

Commit d696148

Browse files
phoflJulianWgs
authored andcommitted
TST: Add test for union with duplicates (pandas-dev#40967)
1 parent 0bcf3e2 commit d696148

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pandas/tests/test_algos.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -2418,10 +2418,16 @@ def test_diff_low_precision_int(self, dtype):
24182418
tm.assert_numpy_array_equal(result, expected)
24192419

24202420

2421-
def test_union_with_duplicates():
2421+
@pytest.mark.parametrize("op", [np.array, pd.array])
2422+
def test_union_with_duplicates(op):
24222423
# GH#36289
2423-
lvals = np.array([3, 1, 3, 4])
2424-
rvals = np.array([2, 3, 1, 1])
2425-
result = algos.union_with_duplicates(lvals, rvals)
2426-
expected = np.array([3, 3, 1, 1, 4, 2])
2427-
tm.assert_numpy_array_equal(result, expected)
2424+
lvals = op([3, 1, 3, 4])
2425+
rvals = op([2, 3, 1, 1])
2426+
expected = op([3, 3, 1, 1, 4, 2])
2427+
if isinstance(expected, np.ndarray):
2428+
result = algos.union_with_duplicates(lvals, rvals)
2429+
tm.assert_numpy_array_equal(result, expected)
2430+
else:
2431+
with tm.assert_produces_warning(RuntimeWarning):
2432+
result = algos.union_with_duplicates(lvals, rvals)
2433+
tm.assert_extension_array_equal(result, expected)

0 commit comments

Comments
 (0)