Skip to content

Fix plot directive with func calls #21661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 21, 2022

Conversation

tacaswell
Copy link
Member

PR Summary

This will close #20656 .

I started but did not get through writing tests, I think I see a way to test just render_figures in a self-contained way, but wanted to push this up so it did not get lost.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@tacaswell tacaswell added this to the v3.6.0 milestone Nov 18, 2021
@QuLogic QuLogic modified the milestones: v3.6.0, v3.7.0 Jul 5, 2022
@tacaswell tacaswell force-pushed the fix_plot_directive_funccalls branch 2 times, most recently from 66b1647 to 674c932 Compare October 20, 2022 23:33
@tacaswell tacaswell marked this pull request as ready for review October 20, 2022 23:34
@tacaswell
Copy link
Member Author

I ended up updating the existing tests which was by far the path of least resistence.

One test change was needed because the output file names changed (because the function name is now in the output file name to prevent them from clobbering each other).

This allows multiple functions from the same file to be called.
Also remove the () from the search so `plt.show(block=True)` will also
be caught.

The reason for this change is so that calling `plt.show()` inside of a function
will not try to split the code into independently executed chunks.
We do not know where it is safe to split the code if we are going to
later call a function for the generated namespace.
There are too many positional arguments and the names are subtly
different.
@tacaswell tacaswell force-pushed the fix_plot_directive_funccalls branch from 674c932 to 1040fb2 Compare November 23, 2022 21:28
@tacaswell tacaswell force-pushed the fix_plot_directive_funccalls branch from 1040fb2 to dd38447 Compare November 23, 2022 22:10
@tacaswell tacaswell force-pushed the fix_plot_directive_funccalls branch 3 times, most recently from c49e2a5 to 8ecc8f2 Compare December 7, 2022 21:40
@tacaswell tacaswell force-pushed the fix_plot_directive_funccalls branch from 5721823 to c2d1662 Compare December 7, 2022 23:02
tacaswell and others added 3 commits December 18, 2022 15:25
Use `else` on for loop to be clearer about what break means.
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
@tacaswell tacaswell force-pushed the fix_plot_directive_funccalls branch from efc9ebd to 947e10a Compare December 18, 2022 20:29
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@tacaswell tacaswell force-pushed the fix_plot_directive_funccalls branch from 947e10a to 1411ba3 Compare December 18, 2022 20:32
@QuLogic
Copy link
Member

QuLogic commented Dec 21, 2022

Doc failure is unrelated.

@QuLogic QuLogic merged commit 4bb1538 into matplotlib:main Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sphinx extension plot_directive not able to detect function
4 participants