Skip to content

Commit 1dded41

Browse files
committed
Parametrize value_counts test
1 parent a8934ed commit 1dded41

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

pandas/tests/test_algos.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -962,27 +962,21 @@ def test_value_counts_uint64(self):
962962
if not compat.is_platform_32bit():
963963
tm.assert_series_equal(result, expected)
964964

965-
def test_value_counts_nonsorted_single_occurance(self):
965+
@pytest.mark.parametrize("sort", [True, False])
966+
def test_value_counts_single_occurance(self, sort):
966967
# GH 12679
968+
if sort == True:
969+
pytest.xfail(reason="sort=True does not guarantee the same order")
970+
967971
# All items occour exactly once.
968972
# No matter if sorted or not, the resulting values should be in
969973
# the same order.
970974
s = Series(list('bacdef'))
971975

972976
# Guarantee the same index if value_counts(sort=False) is used
973-
vc = s.value_counts(sort=False, ascending=False)
974-
tm.assert_series_equal(Series(vc.index), s)
975-
vc = s.value_counts(sort=False, ascending=True)
976-
tm.assert_series_equal(Series(vc.index), s)
977-
978-
@pytest.mark.xfail(reason="sort=True does not guarantee the same order")
979-
def test_value_counts_sorted_single_occurance(self):
980-
# GH 12679
981-
s = Series(list('bacdef'))
982-
# Guarantee does not hold yet for the sort=True case
983-
vc = s.value_counts(sort=True, ascending=False)
977+
vc = s.value_counts(sort=sort, ascending=False)
984978
tm.assert_series_equal(Series(vc.index), s)
985-
vc = s.value_counts(sort=True, ascending=True)
979+
vc = s.value_counts(sort=sort, ascending=True)
986980
tm.assert_series_equal(Series(vc.index), s)
987981

988982
def test_value_counts_nonsorted_double_occurance(self):

0 commit comments

Comments
 (0)