|
4 | 4 | We test the describe_ndframe function. |
5 | 5 | """ |
6 | 6 |
|
7 | | -import pytest |
8 | 7 | import numpy as np |
| 8 | +import pytest |
9 | 9 |
|
10 | 10 | from pandas.core.methods.describe import _refine_percentiles |
11 | 11 |
|
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): |
13 | 20 | """ |
14 | 21 | Check the performance of the _refine_percentiles when multiple |
15 | 22 | values are passed. |
16 | 23 | """ |
17 | 24 |
|
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