Skip to content

Commit 5f5f4cb

Browse files
committed
Update fixture
1 parent 67ead68 commit 5f5f4cb

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

pandas/tests/indexes/test_range.py

+54-54
Original file line numberDiff line numberDiff line change
@@ -578,62 +578,62 @@ def test_union_noncomparable(self):
578578
expected = Index(np.concatenate((other, self.index)))
579579
tm.assert_index_equal(result, expected)
580580

581-
@pytest.fixture
582-
def union_fixture(self):
581+
RI = RangeIndex
582+
I64 = Int64Index
583+
584+
@pytest.fixture(params=[
585+
(RI(0, 10, 1), RI(0, 10, 1), RI(0, 10, 1), RI(0, 10, 1)),
586+
(RI(0, 10, 1), RI(5, 20, 1), RI(0, 20, 1), I64(range(20))),
587+
(RI(0, 10, 1), RI(10, 20, 1), RI(0, 20, 1), I64(range(20))),
588+
(RI(0, -10, -1), RI(0, -10, -1), RI(0, -10, -1), RI(0, -10, -1)),
589+
(RI(0, -10, -1), RI(-10, -20, -1), RI(-19, 1, 1),
590+
I64(range(0, -20, -1))),
591+
(RI(0, 10, 2), RI(1, 10, 2), RI(0, 10, 1),
592+
I64(list(range(0, 10, 2)) + list(range(1, 10, 2)))),
593+
(RI(0, 11, 2), RI(1, 12, 2), RI(0, 12, 1),
594+
I64(list(range(0, 11, 2)) + list(range(1, 12, 2)))),
595+
(RI(0, 21, 4), RI(-2, 24, 4), RI(-2, 24, 2),
596+
I64(list(range(0, 21, 4)) + list(range(-2, 24, 4)))),
597+
(RI(0, -20, -2), RI(-1, -21, -2), RI(-19, 1, 1),
598+
I64(list(range(0, -20, -2)) + list(range(-1, -21, -2)))),
599+
(RI(0, 100, 5), RI(0, 100, 20), RI(0, 100, 5), I64(range(0, 100, 5))),
600+
(RI(0, -100, -5), RI(5, -100, -20), RI(-95, 10, 5),
601+
I64(list(range(0, -100, -5)) + [5])),
602+
(RI(0, -11, -1), RI(1, -12, -4), RI(-11, 2, 1),
603+
I64(list(range(0, -11, -1)) + [1, -11])),
604+
(RI(0), RI(0), RI(0), RI(0)),
605+
(RI(0, -10, -2), RI(0), RI(0, -10, -2), RI(0, -10, -2)),
606+
(RI(0, 100, 2), RI(100, 150, 200), RI(0, 102, 2),
607+
I64(range(0, 102, 2))),
608+
(RI(0, -100, -2), RI(-100, 50, 102), RI(-100, 4, 2),
609+
I64(list(range(0, -100, -2)) + [-100, 2])),
610+
(RI(0, -100, -1), RI(0, -50, -3), RI(-99, 1, 1),
611+
I64(list(range(0, -100, -1)))),
612+
(RI(0, 1, 1), RI(5, 6, 10), RI(0, 6, 5), I64([0, 5])),
613+
(RI(0, 10, 5), RI(-5, -6, -20), RI(-5, 10, 5), I64([0, 5, -5])),
614+
(RI(0, 3, 1), RI(4, 5, 1), I64([0, 1, 2, 4]), I64([0, 1, 2, 4])),
615+
(RI(0, 10, 1), I64([]), RI(0, 10, 1), RI(0, 10, 1)),
616+
(RI(0), I64([1, 5, 6]), I64([1, 5, 6]), I64([1, 5, 6]))
617+
])
618+
def unions(self, request):
583619
"""Inputs and expected outputs for RangeIndex.union tests"""
584-
RI = RangeIndex
585-
I64 = Int64Index
586620

587-
return [(RI(0, 10, 1), RI(0, 10, 1), RI(0, 10, 1), RI(0, 10, 1)),
588-
(RI(0, 10, 1), RI(5, 20, 1), RI(0, 20, 1), I64(range(20))),
589-
(RI(0, 10, 1), RI(10, 20, 1), RI(0, 20, 1), I64(range(20))),
590-
(RI(0, -10, -1), RI(0, -10, -1), RI(0, -10, -1),
591-
RI(0, -10, -1)),
592-
(RI(0, -10, -1), RI(-10, -20, -1), RI(-19, 1, 1),
593-
I64(range(0, -20, -1))),
594-
(RI(0, 10, 2), RI(1, 10, 2), RI(0, 10, 1),
595-
I64(list(range(0, 10, 2)) + list(range(1, 10, 2)))),
596-
(RI(0, 11, 2), RI(1, 12, 2), RI(0, 12, 1),
597-
I64(list(range(0, 11, 2)) + list(range(1, 12, 2)))),
598-
(RI(0, 21, 4), RI(-2, 24, 4), RI(-2, 24, 2),
599-
I64(list(range(0, 21, 4)) + list(range(-2, 24, 4)))),
600-
(RI(0, -20, -2), RI(-1, -21, -2), RI(-19, 1, 1),
601-
I64(list(range(0, -20, -2)) + list(range(-1, -21, -2)))),
602-
(RI(0, 100, 5), RI(0, 100, 20), RI(0, 100, 5),
603-
I64(range(0, 100, 5))),
604-
(RI(0, -100, -5), RI(5, -100, -20), RI(-95, 10, 5),
605-
I64(list(range(0, -100, -5)) + [5])),
606-
(RI(0, -11, -1), RI(1, -12, -4), RI(-11, 2, 1),
607-
I64(list(range(0, -11, -1)) + [1, -11])),
608-
(RI(0), RI(0), RI(0), RI(0)),
609-
(RI(0, -10, -2), RI(0), RI(0, -10, -2), RI(0, -10, -2)),
610-
(RI(0, 100, 2), RI(100, 150, 200), RI(0, 102, 2),
611-
I64(range(0, 102, 2))),
612-
(RI(0, -100, -2), RI(-100, 50, 102), RI(-100, 4, 2),
613-
I64(list(range(0, -100, -2)) + [-100, 2])),
614-
(RI(0, -100, -1), RI(0, -50, -3), RI(-99, 1, 1),
615-
I64(list(range(0, -100, -1)))),
616-
(RI(0, 1, 1), RI(5, 6, 10), RI(0, 6, 5), I64([0, 5])),
617-
(RI(0, 10, 5), RI(-5, -6, -20), RI(-5, 10, 5),
618-
I64([0, 5, -5])),
619-
(RI(0, 3, 1), RI(4, 5, 1), I64([0, 1, 2, 4]),
620-
I64([0, 1, 2, 4])),
621-
(RI(0, 10, 1), I64([]), RI(0, 10, 1), RI(0, 10, 1)),
622-
(RI(0), I64([1, 5, 6]), I64([1, 5, 6]), I64([1, 5, 6]))]
623-
624-
def test_union_sorted(self, union_fixture):
625-
626-
for (idx1, idx2, expected_sorted, expected_notsorted) in union_fixture:
627-
res1 = idx1.union(idx2, sort=None)
628-
tm.assert_index_equal(res1, expected_sorted, exact=True)
629-
630-
res1 = idx1.union(idx2, sort=False)
631-
tm.assert_index_equal(res1, expected_notsorted, exact=True)
632-
633-
res2 = idx2.union(idx1, sort=None)
634-
res3 = idx1._int64index.union(idx2, sort=None)
635-
tm.assert_index_equal(res2, expected_sorted, exact=True)
636-
tm.assert_index_equal(res3, expected_sorted)
621+
return request.param
622+
623+
def test_union_sorted(self, unions):
624+
625+
idx1, idx2, expected_sorted, expected_notsorted = unions
626+
627+
res1 = idx1.union(idx2, sort=None)
628+
tm.assert_index_equal(res1, expected_sorted, exact=True)
629+
630+
res1 = idx1.union(idx2, sort=False)
631+
tm.assert_index_equal(res1, expected_notsorted, exact=True)
632+
633+
res2 = idx2.union(idx1, sort=None)
634+
res3 = idx1._int64index.union(idx2, sort=None)
635+
tm.assert_index_equal(res2, expected_sorted, exact=True)
636+
tm.assert_index_equal(res3, expected_sorted)
637637

638638
def test_nbytes(self):
639639

0 commit comments

Comments
 (0)