Skip to content

Commit dd875da

Browse files
committed
use pytest mark parametrize to fix input and expected values
1 parent c1c1879 commit dd875da

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

pandas/tests/reductions/test_describe_ndframe.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,22 @@
44
We test the describe_ndframe function.
55
"""
66

7-
import pytest
87
import numpy as np
8+
import pytest
99

1010
from pandas.core.methods.describe import _refine_percentiles
1111

12-
def test_refine_percentiles():
12+
@pytest.mark.parametrize(
13+
"percentiles_, expected", [
14+
(None, np.array([0.25, 0.5, 0.75])),
15+
([], np.array([0.5])),
16+
([0.3, 0.6], np.array([0.3, 0.6])),
17+
]
18+
)
19+
def test_refine_percentiles(percentiles_, expected):
1320
"""
1421
Check the performance of the _refine_percentiles when multiple
1522
values are passed.
1623
"""
1724

18-
# by default 0.25, 0.50, 0.75 is returned
19-
# or, when None is passed return behavior is the same
20-
assert _refine_percentiles() == np.array([0.25, 0.5, 0.75])
21-
assert _refine_percentiles(percentiles = None) == np.array([0.25, 0.5, 0.75])
22-
23-
# when any value is passed, then the function should return
24-
percentiles_ = [0.3, 0.6]
25-
assert _refine_percentiles(percentiles_) == np.array(percentiles_)
26-
27-
# when a blank list is passed, then should return only 0.5
28-
assert _refine_percentiles(percentiles = []) == np.array([0.5])
25+
assert np.array_equal(_refine_percentiles(percentiles_), expected)

0 commit comments

Comments
 (0)