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

Commiteef76b1

Browse files
committed
Make NavigationToolbar.configure_subplots return value consistent
When the subplot tool already exists, then it is shown, but neverreturned. This seems to be an accident.
1 parent9120862 commiteef76b1

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

‎lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3244,7 +3244,7 @@ def _update_view(self):
32443244
defconfigure_subplots(self,*args):
32453245
ifhasattr(self,"subplot_tool"):
32463246
self.subplot_tool.figure.canvas.manager.show()
3247-
return
3247+
returnself.subplot_tool
32483248
# This import needs to happen here due to circular imports.
32493249
frommatplotlib.figureimportFigure
32503250
withmpl.rc_context({"toolbar":"none"}):# No navbar for the toolfig.

‎lib/matplotlib/backend_bases.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ class NavigationToolbar2:
475475
defrelease_zoom(self,event:Event)->None: ...
476476
defpush_current(self)->None: ...
477477
subplot_tool:widgets.SubplotTool
478-
defconfigure_subplots(self,*args): ...
478+
defconfigure_subplots(self,*args:Any)->widgets.SubplotTool: ...
479479
defsave_figure(self,*args)->str|None|object: ...
480480
defupdate(self)->None: ...
481481
defset_history_buttons(self)->None: ...

‎lib/matplotlib/tests/test_backend_qt.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ def set_device_pixel_ratio(ratio):
213213
deftest_subplottool():
214214
fig,ax=plt.subplots()
215215
withmock.patch("matplotlib.backends.qt_compat._exec",lambdaobj:None):
216-
fig.canvas.manager.toolbar.configure_subplots()
216+
tool=fig.canvas.manager.toolbar.configure_subplots()
217+
asserttoolisnotNone
218+
asserttool==fig.canvas.manager.toolbar.configure_subplots()
217219

218220

219221
@pytest.mark.backend('QtAgg',skip_on_importerror=True)

‎lib/matplotlib/tests/test_backend_tk.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ def test_never_update():
168168
plt.show(block=False)
169169

170170
plt.draw()# Test FigureCanvasTkAgg.
171-
fig.canvas.toolbar.configure_subplots()# Test NavigationToolbar2Tk.
171+
tool=fig.canvas.toolbar.configure_subplots()# Test NavigationToolbar2Tk.
172+
asserttoolisnotNone
173+
asserttool==fig.canvas.toolbar.configure_subplots()# Tool is reused internally.
172174
# Test FigureCanvasTk filter_destroy callback
173175
fig.canvas.get_tk_widget().after(100,plt.close,fig)
174176

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp