Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add __all__ to pyplot#12743

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
timhoffm wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromtimhoffm:pyplot-all
Draft

Conversation

timhoffm
Copy link
Member

@timhoffmtimhoffm commentedNov 4, 2018
edited
Loading

PR Summary

This introduces the__all__ variable to pyplot, whose only purpose is to limit what is imported on a wildcard importfrom matplotlib.pyplot import *.

While wildcard imports are not recommended in general - and I don't want to change this, there appears to be still a lot offrom pylab import * oripython --pylab usage around. I assume that's because it's so convenient for quick interactive use. While we probably cannot change people completely, it may be a good idea to have a more limited and thus less dangerous wildcard import to help push people away from pylab. In particular we should only import relevant plotting functions here (no numpy, no mlab, no colormap functions)

Note: This is currently a proof of concept and requires additional work.

  • This affectspylab since pylab usesfrom matplotlib.pyplot import *, which is an unintended side-effect.
  • The hard-coded part of functions in__all__ needs some cleanup. Possible some are missing, while others are not neccesary.

But before working futher on the details, I would like to reach a general consensus on the idea.

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 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

dpshelio and story645 reacted with thumbs up emoji
@timhoffm
Copy link
MemberAuthor

Note: CI for 3.5 is currently failing due to non-deterministic dict order. This can be worked around or defered until mpl 3.1, which will be python 3.6+ only. Not going to spend time on this before the general idea is discussed.

@timhoffmtimhoffm added this to thev3.1 milestoneNov 4, 2018
@ImportanceOfBeingErnest
Copy link
Member

You can be certain that a lot of people do things like

axes().add_artist(Rectangle((.5,.5),.2,.3, color=cm.magma(.4)))

having startedipython --pylab.

@timhoffm
Copy link
MemberAuthor

Except for thecm.magma, which would have to be discussed, this is fine by me.

This is about defining a reasonable subset of pylab that should ease most use-cases while limiting the number of imported functions.

@timhoffmtimhoffm modified the milestones:v3.1.0,v3.2.0Feb 15, 2019
@dpshelio
Copy link

I've found out about this problem today. Very confusing the fact that one can access the wholematpltolib and other things likesys andtime when imported everything frompyplot. It's very confusing seen scripts like:

frommatplotlib.pyplotimport*...matplotlib.pyplot.savefig('myimage.png')

I really support this change!

@timhoffmtimhoffm modified the milestones:v3.2.0,v3.3.0Aug 7, 2019
@timhoffmtimhoffm modified the milestones:v3.3.0,v3.4.0Apr 11, 2020
@timhoffmtimhoffm marked this pull request as draftJuly 14, 2020 21:20
@QuLogicQuLogic modified the milestones:v3.4.0,v3.5.0Jan 21, 2021
@timhoffmtimhoffm modified the milestones:v3.5.0,unassignedJul 8, 2021
@story645story645 modified the milestones:unassigned,needs sortingOct 6, 2022
@tacaswelltacaswell marked this pull request as ready for reviewDecember 5, 2022 23:33
@tacaswell
Copy link
Member

I took the liberty of rebasing this and think it is ready to review.

@tacaswelltacaswell modified the milestones:v3.7.0,v3.8.0Dec 9, 2022
@tacaswell
Copy link
Member

I think this needs a behavior change note indicating that we restricted the namespace, but otherwise 👍

Copy link
Member

@oscargusoscargus 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 makes sense. Will also help with#22149.

@timhoffm
Copy link
MemberAuthor

Happy to see this moving. Please be aware that this may not yet be ready

Note: This is currently a proof of concept and requires additional work.

  • This affectspylab since pylab usesfrom matplotlib.pyplot import *, which is an unintended side-effect.
  • The hard-coded part of functions in__all__ needs some cleanup. Possible some are missing, while others are not neccesary.

I'm sorry I don't have the time to work on this. Anybody can take over the PR and (force) push.

@jklymak
Copy link
Member

Lets move to draft, but definitely anyone should feel free to put back...

@jklymakjklymak marked this pull request as draftJanuary 24, 2023 17:19
@QuLogicQuLogic mentioned this pull requestMar 9, 2023
5 tasks
@github-actions
Copy link

Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it.

@github-actionsgithub-actionsbot added the status: inactiveMarked by the “Stale” Github Action labelMay 30, 2023
@timhoffmtimhoffm added keepItems to be ignored by the “Stale” Github Action and removed status: inactiveMarked by the “Stale” Github Action labelsMay 31, 2023
@timhoffmtimhoffmforce-pushed thepyplot-all branch 2 times, most recently frome9d8ff2 toe2c9eb9CompareMay 31, 2023 05:34
@timhoffm
Copy link
MemberAuthor

Rebased, but#12743 (comment) still applies.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@oscargusoscargusoscargus approved these changes

Assignees
No one assigned
Labels
keepItems to be ignored by the “Stale” Github Actionstatus: needs rebasestatus: work in progress
Projects
None yet
Milestone
future releases
Development

Successfully merging this pull request may close these issues.

8 participants
@timhoffm@ImportanceOfBeingErnest@dpshelio@tacaswell@jklymak@oscargus@QuLogic@story645

[8]ページ先頭

©2009-2025 Movatter.jp