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

Remove custom backend_nbagg.show(), putting logic in manager show.#23100

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

Merged
tacaswell merged 1 commit intomatplotlib:mainfromanntzer:nbucs
Jun 24, 2022
Merged
Changes fromall 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
33 changes: 9 additions & 24 deletionslib/matplotlib/backends/backend_nbagg.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,6 +96,15 @@ def show(self):
else:
self.canvas.draw_idle()
self._shown = True
# plt.figure adds an event which makes the figure in focus the active
# one. Disable this behaviour, as it results in figures being put as
# the active figure after they have been shown, even in non-interactive
# mode.
if hasattr(self, '_cidgcf'):
Copy link
Member

Choose a reason for hiding this comment

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

Is there any way to add tests to argue that this is working as expected?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Actually, there was previously no test coverage for the corresponding old code paths (as can be checked e.g. viapytest --cov --pyargs matplotlib.tests.test_backend_nbagg && coverage html: the entire show() function was untested), so I'll ask for an out there and just point out that I simply moved some code around (also, my understanding of nbagg is on the weaker side...).

Copy link
Member

Choose a reason for hiding this comment

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

fair.

self.canvas.mpl_disconnect(self._cidgcf)
if not is_interactive():
from matplotlib._pylab_helpers import Gcf
Gcf.figs.pop(self.num, None)

def reshow(self):
"""
Expand DownExpand Up@@ -232,27 +241,3 @@ def on_message(self, message):
class _BackendNbAgg(_Backend):
FigureCanvas = FigureCanvasNbAgg
FigureManager = FigureManagerNbAgg

@staticmethod
def show(block=None):
## TODO: something to do when keyword block==False ?
from matplotlib._pylab_helpers import Gcf

managers = Gcf.get_all_fig_managers()
if not managers:
return

interactive = is_interactive()

for manager in managers:
manager.show()

# plt.figure adds an event which makes the figure in focus the
# active one. Disable this behaviour, as it results in
# figures being put as the active figure after they have been
# shown, even in non-interactive mode.
if hasattr(manager, '_cidgcf'):
manager.canvas.mpl_disconnect(manager._cidgcf)

if not interactive:
Gcf.figs.pop(manager.num, None)

[8]ページ先頭

©2009-2025 Movatter.jp