eschutho opened a new pull request, #42272:
URL: https://github.com/apache/superset/pull/42272

   ### What was the warning
   
   Production logs show a pandas `FutureWarning` from 
`superset/utils/pandas_postprocessing/aggregate.py:46` 
(`df_groupby.agg(**aggregate_funcs)`), for the `max`/`min` operators 
specifically:
   
   ```
   FutureWarning: The provided callable <function max at 0x...> is currently 
using SeriesGroupBy.max. In a future version of pandas, the provided callable 
will be used directly. To keep current behavior pass the string "max" instead.
   ```
   
   #42004 already fixed this exact warning class for `mean`/`median` in 
`boxplot()`, by passing the strings `"mean"`/`"median"` instead of 
`np.mean`/`np.median`. It missed that the `MINMAX` whisker type sets 
`whisker_high = np.max` and `whisker_low = np.min` — also bare numpy callables 
— which get passed straight through into the same `aggregates` dict and trip 
the identical warning.
   
   ### What changed
   
   Extends the #42004 pattern to `max`/`min`, but only for the `MINMAX` branch: 
`"max" if is_minmax else whisker_high` / `"min" if is_minmax else whisker_low` 
in the `operators` dict used to build the aggregate config. 
`whisker_high`/`whisker_low` themselves are untouched — they're still used as 
real callables in the `outliers()` closure, and in the `TUKEY`/`PERCENTILE` 
branches they're custom closures (not bare numpy functions), so they're 
unaffected by this change.
   
   ### No behavior change
   
   Per the warning's own text, pandas currently resolves the callable form to 
the exact same aggregation as the string form (`SeriesGroupBy.max`/`.min`) — 
passing the string just opts into that same behavior explicitly and silences 
the warning. Only a *future* pandas version would change what the callable form 
does.
   
   ### Test plan
   
   Added `test_boxplot_minmax_no_future_warning`, mirroring the existing 
`test_boxplot_mean_median_no_future_warning`: asserts no `FutureWarning` is 
raised under `MINMAX`, and that the resulting `max`/`min` columns match a plain 
`groupby(...).agg(["max", "min"])` call. Verified this test fails on the 
pre-fix code and passes after the fix. Full 
`tests/unit_tests/pandas_postprocessing/test_boxplot.py` suite (7 tests) 
passes; `ruff check`, `ruff format --check`, and the repo's `pre-commit` (mypy, 
pylint, etc.) all pass clean on the diff.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to