-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Minor simplification to _pylab_helpers. #10090
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,10 @@ | |
unicode_literals) | ||
|
||
import six | ||
import sys | ||
import gc | ||
import atexit | ||
|
||
|
||
def error_msg(msg): | ||
print(msg, file=sys.stderr) | ||
import atexit | ||
import gc | ||
import sys | ||
|
||
|
||
class Gcf(object): | ||
|
@@ -58,27 +55,16 @@ def destroy(cls, num): | |
return | ||
manager = cls.figs[num] | ||
manager.canvas.mpl_disconnect(manager._cidgcf) | ||
|
||
# There must be a good reason for the following careful | ||
# rebuilding of the activeQue; what is it? | ||
oldQue = cls._activeQue[:] | ||
cls._activeQue = [] | ||
for f in oldQue: | ||
if f != manager: | ||
cls._activeQue.append(f) | ||
|
||
cls._activeQue.remove(manager) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The functional difference here is that the old code replaces the class attribute |
||
del cls.figs[num] | ||
manager.destroy() | ||
gc.collect(1) | ||
|
||
@classmethod | ||
def destroy_fig(cls, fig): | ||
"*fig* is a Figure instance" | ||
num = None | ||
for manager in six.itervalues(cls.figs): | ||
if manager.canvas.figure == fig: | ||
num = manager.num | ||
break | ||
num = next((manager.num for manager in six.itervalues(cls.figs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's an interesting pattern. |
||
if manager.canvas.figure == fig), None) | ||
if num is not None: | ||
cls.destroy(num) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious: why did you bother re-ordering these imports? The original order looks fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping things in alphabetical order. A bit anal, I admit.