Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pyplot.style.use() to accept pathlib.Path objects as arguments #15149

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 12 commits into from
Sep 8, 2019

Conversation

omsitapara23
Copy link
Contributor

@omsitapara23 omsitapara23 commented Aug 28, 2019

PR Summary

Currently the pyplot.style.use() supports strings, list, and dic as function arguments where string can be a library style or path/URL to style file. Added the code to leverage the function to use pathlib.Path object as an argument.
Fixes #15138

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a great start, but if we are going to take just a Path then we also need to support List[Path].

@tacaswell tacaswell added this to the v3.3.0 milestone Aug 28, 2019
@ivarstange
Copy link

There's also a context manager in the same file that basically wraps use(). This too accepts Path once use does. So maybe update the doc on that one as well?

@tacaswell
Copy link
Member

Thanks for working on this @omsitapara23 !

…dated code and comments according to reviews
@omsitapara23
Copy link
Contributor Author

omsitapara23 commented Aug 29, 2019

Hi @tacaswell, and @QuLogic

I have done all the requested changes.
Summary of changes till now ( for future reference ):

  • plt.style.use() function to allow single Path object or List (the combination of Path, str, and dict ).
  • No explicit type cast from Path object to str has been performed.
  • Also changed the code comments of plt.style.use() along with of context manager as suggested by @ivarstange

Thank you
Om.

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test in lib/matplotlib/tests/test_style.py that Paths works.

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test can be simplified, but otherwise seems fine. Also, there are quite a few commits; they probably be squashed down a bit.

omsitapara23 and others added 2 commits September 7, 2019 15:38
Co-Authored-By: Elliott Sales de Andrade <[email protected]>
Co-Authored-By: Elliott Sales de Andrade <[email protected]>
@timhoffm timhoffm dismissed tacaswell’s stale review September 7, 2019 12:32

Mutliple paths are now supported.

@timhoffm
Copy link
Member

timhoffm commented Sep 7, 2019

@tacaswell Can we still bring this into 3.2? I think it's a nice addition.

changed the comments according to numpydoc

Co-Authored-By: Tim Hoffmann <[email protected]>
@timhoffm timhoffm modified the milestones: v3.3.0, v3.2.0 Sep 8, 2019
@timhoffm timhoffm merged commit 98507c0 into matplotlib:master Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make plt.style.use accept path-like objects in addition to string
6 participants