Adding Scalar as a Baseline Option#27308
Adding Scalar as a Baseline Option#27308EricRLeao1311 wants to merge 14 commits intomatplotlib:mainfrom
Conversation
|
I think that restricting to an I also think that perhaps even more important than the code change allowing |
|
I'm pair programming alongside @EricRLeao1311. We've changed to code so it accepts floats, but we still have some questions about testing and documentation. About testing, how could we improve/fix it? We found some tests in test_axes.py, but they use a @image_comparison wrapper, and we are unsure on how to make it work for our case. We tried to include some cases, but we don't know if they were made correctly. And about documentation, we attempted to improve the docstrings related to the function. Is that enough? Thanks! |
| try: | ||
| axs[0, 0].stackplot(range(100), d.T, baseline=5) | ||
| except ValueError as e: | ||
| print("Error when using an integer as baseline:", e) |
There was a problem hiding this comment.
If you are testing something that should fail the test if the error is raised, then remove the try/except.
If you are testing that this should raise, then use with pytest.raises(...) which will ensure that the exception is actually raised (where printing will just ignore whether or not an exception was raised)
|
I still think float is too restrictive, and that we should be looking at unit-aware changes, so while |
|
Ok, I see that you want it to be more expansive than float-only, but we are having trouble on what types we should accept and how to treat the different types. Could you enlighten us in any type of way? |
|
Because the units system can have arbitrary values, there is no restriction on the type, much like the https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.bar.html This should be treated similarly, in that it gets passed through matplotlib/lib/matplotlib/axes/_axes.py Line 2426 in eb02b10 Where this has odd behavior:
I think that it could be:
|
PR summary
Allowing an int to be received as a baseline option in stackplots, to prevent cases where the baseline is not sensible enough.
Closes #27129
PR checklist