Skip to content

Commit

Permalink
PERF: Fix quantile perf regression (#35101)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger committed Jul 3, 2020
1 parent a6b5e16 commit 7e25af8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pandas/util/_validators.py
Expand Up @@ -371,14 +371,13 @@ def validate_percentile(q: Union[float, Iterable[float]]) -> np.ndarray:
ValueError if percentiles are not in given interval([0, 1]).
"""
q_arr = np.asarray(q)
msg = (
"percentiles should all be in the interval [0, 1]."
f"Try {q_arr / 100.0} instead."
)
# Don't change this to an f-string. The string formatting
# is too expensive for cases where we don't need it.
msg = "percentiles should all be in the interval [0, 1]. Try {} instead."
if q_arr.ndim == 0:
if not 0 <= q_arr <= 1:
raise ValueError(msg)
raise ValueError(msg.format(q_arr / 100.0))
else:
if not all(0 <= qs <= 1 for qs in q_arr):
raise ValueError(msg)
raise ValueError(msg.format(q_arr / 100.0))
return q_arr

0 comments on commit 7e25af8

Please sign in to comment.