Skip to content

Commit

Permalink
use pytest mark parametrize to fix input and expected values
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenithClown committed Dec 18, 2024
1 parent c1c1879 commit dd875da
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions pandas/tests/reductions/test_describe_ndframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,22 @@
We test the describe_ndframe function.
"""

import pytest
import numpy as np
import pytest

from pandas.core.methods.describe import _refine_percentiles

def test_refine_percentiles():
@pytest.mark.parametrize(
"percentiles_, expected", [
(None, np.array([0.25, 0.5, 0.75])),
([], np.array([0.5])),
([0.3, 0.6], np.array([0.3, 0.6])),
]
)
def test_refine_percentiles(percentiles_, expected):
"""
Check the performance of the _refine_percentiles when multiple
values are passed.
"""

# by default 0.25, 0.50, 0.75 is returned
# or, when None is passed return behavior is the same
assert _refine_percentiles() == np.array([0.25, 0.5, 0.75])
assert _refine_percentiles(percentiles = None) == np.array([0.25, 0.5, 0.75])

# when any value is passed, then the function should return
percentiles_ = [0.3, 0.6]
assert _refine_percentiles(percentiles_) == np.array(percentiles_)

# when a blank list is passed, then should return only 0.5
assert _refine_percentiles(percentiles = []) == np.array([0.5])
assert np.array_equal(_refine_percentiles(percentiles_), expected)

0 comments on commit dd875da

Please sign in to comment.