Skip to content

Commit 5b38f2a

Browse files
Lena Kashtelyanfacebook-github-bot
Lena Kashtelyan
authored andcommitted
Address numpy deprecation warning (#2272)
Summary: Pull Request resolved: #2272 Address this warning that was coming up in the tests: ``` ax/plot/trace.py:500: DeprecationWarning: the `interpolation=` argument to percentile was renamed to `method=`, which has additional options. Users of the modes 'nearest', 'lower', 'higher', or 'midpoint' are encouraged to review the method they used. (Deprecated NumPy 1.22) q1 = np.percentile(y, q=25, interpolation="lower").min() ``` Reviewed By: saitcakmak Differential Revision: D51443080 fbshipit-source-id: b131f158607fb739a0068cb2daad60477b6d2448
1 parent 68bc41c commit 5b38f2a

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

ax/modelbridge/transforms/winsorize.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,8 @@ def _get_tukey_cutoffs(Y: np.ndarray, lower: bool) -> float:
349349
350350
See https://mathworld.wolfram.com/Box-and-WhiskerPlot.html for more details.
351351
"""
352-
# TODO: replace interpolation->method once it becomes standard.
353-
q1 = np.percentile(Y, q=25, interpolation="lower")
354-
q3 = np.percentile(Y, q=75, interpolation="higher")
352+
q1 = np.percentile(Y, q=25, method="lower")
353+
q3 = np.percentile(Y, q=75, method="higher")
355354
iqr = q3 - q1
356355
return q1 - 1.5 * iqr if lower else q3 + 1.5 * iqr
357356

ax/plot/diagnostic.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,8 @@ def _obs_vs_pred_dropdown_plot(
131131
min_, max_ = _get_min_max_with_errors(y_raw, y_hat, se_raw, se_hat)
132132
if autoset_axis_limits:
133133
y_raw_np = np.array(y_raw)
134-
# TODO: replace interpolation->method once it becomes standard.
135-
q1 = np.nanpercentile(y_raw_np, q=25, interpolation="lower").min()
136-
q3 = np.nanpercentile(y_raw_np, q=75, interpolation="higher").max()
134+
q1 = np.nanpercentile(y_raw_np, q=25, method="lower").min()
135+
q3 = np.nanpercentile(y_raw_np, q=75, method="higher").max()
137136
y_lower = q1 - 1.5 * (q3 - q1)
138137
y_upper = q3 + 1.5 * (q3 - q1)
139138
y_raw_np = y_raw_np.clip(y_lower, y_upper).tolist()

ax/plot/trace.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,10 @@ def _autoset_axis_limits(
461461
If `force_include_value` is provided, the worst points will be truncated at this
462462
value if it is worse than the truncation point described above.
463463
"""
464-
# TODO: replace interpolation->method once it becomes standard.
465-
q1 = np.percentile(y, q=25, interpolation="lower").min()
466-
q2_min = np.percentile(y, q=50, interpolation="linear").min()
467-
q2_max = np.percentile(y, q=50, interpolation="linear").max()
468-
q3 = np.percentile(y, q=75, interpolation="higher").max()
464+
q1 = np.percentile(y, q=25, method="lower").min()
465+
q2_min = np.percentile(y, q=50, method="linear").min()
466+
q2_max = np.percentile(y, q=50, method="linear").max()
467+
q3 = np.percentile(y, q=75, method="higher").max()
469468
if optimization_direction == "minimize":
470469
y_lower = y.min()
471470
y_upper = q2_max + 1.5 * (q2_max - q1)

0 commit comments

Comments
 (0)