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

Skip to content

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

Merged
merged 1 commit into from
Dec 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions lib/matplotlib/_pylab_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

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.

Copy link
Contributor Author

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.



class Gcf(object):
Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The 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 _activeQue, while the new code modifies the original. The only way I can see this would make a difference would be if there were other references to _activeQue. It doesn't look like that should occur; and if it did, I don't see how the replacement would be helpful. Therefore, I think this is OK.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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)

Expand Down