arviz-devs / arviz

Exploratory analysis of Bayesian models with Python
https://python.arviz.org
Apache License 2.0
1.56k stars 386 forks source link

Refactor plot_ecdf arguments #2316

Closed sethaxen closed 3 weeks ago

sethaxen commented 4 months ago

Description

This PR introduces new keyword arguments to plot_ecdf and deprecates a few existing ones, following suggestions in #2309.

New keywords and features:

Deprecated arguments:

Deprecated keywords:

Deprecated rcparams:

Additional changes:

None of the changes are breaking.

Checklist


📚 Documentation preview 📚: https://arviz--2316.org.readthedocs.build/en/2316/

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 90.24390% with 8 lines in your changes missing coverage. Please review.

Project coverage is 87.01%. Comparing base (3a454f7) to head (f414ab0).

Files Patch % Lines
arviz/rcparams.py 71.42% 4 Missing :warning:
arviz/plots/ecdfplot.py 94.00% 3 Missing :warning:
arviz/plots/bpvplot.py 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2316 +/- ## ========================================== + Coverage 86.97% 87.01% +0.04% ========================================== Files 123 123 Lines 12733 12771 +38 ========================================== + Hits 11074 11113 +39 + Misses 1659 1658 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sethaxen commented 4 months ago

@OriolAbril when you get a chance, can you take a look at this?

review-notebook-app[bot] commented 3 months ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

sethaxen commented 3 months ago

@OriolAbril I've implemented all suggestions and updated the above description and changelog. This should be ready for final review.

sethaxen commented 3 months ago

After seeing the warnings and trying it out I am a bit on the fence on the behaviour of eval_points. It is basically a required argument right now, otherwise you get a FutureWarning.

It would be nice to continue allowing plot_ecdf(samples) to work without warnings.

The reason it raises a FutureWarning is because in the future plot_ecdf(samples) will do something entirely different than it does now. The alternative is that we currently don't raise a warning and instead change the behavior in the future without warning. Personally, I think the way we do it here could be less jarring.

OriolAbril commented 3 months ago

Maybe we could create a specific warning class for this? Something like BehaviourChangeWarning, I think it might signal better what is happening and also make it easier to silence (I am quite sure many users don't really care about the default as long as it works) and plot_ecdf(samples) will continue to work.

We could also silence it in the examples of the docstring. Now all examples use eval_points, but to illustrate how to generate confidence bands or how to make it a difference plot it doesn't matter which is the default behaviour of eval_points (and tests don't use it). So we could use the first example to describe the behaviour change, show how to maintain old behaviour and then silence the warning so following examples focus on what they want to illustrate without worrying about the warning.

What do you think?

OriolAbril commented 3 weeks ago

@sethaxen I have tried out the special warning and added the filter to the docs. Now we should make sure all examples in the docstring don't trigger any warning, I have to go now, so leaving this here so when I come back later I can check the docs preview instead of locally building it myself at some point

OriolAbril commented 3 weeks ago

Should be ready to merge now. There is one example in the docstring that triggers a warning, the one for

Plot an ECDF plot with confidence bands for comparing a given sample to a given distribution. We manually specify evaluation points independent of the values so that the confidence bands are correctly calibrated.

because rvs is not provided, I think this is only temporal though, is that right? Once the new default is available there won't be a warning when using that same code snippet