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

Commit0d8c471

Browse files
committed
Smaller review changes
1 parentbc5d384 commit0d8c471

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

‎lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,8 +2039,7 @@ def _switch_canvas_and_return_print_method(self, fmt, backend=None):
20392039
ifbackendisnotNone:
20402040
# Return a specific canvas class, if requested.
20412041
from .backends.registryimportbackend_registry
2042-
canvas_class= (
2043-
backend_registry.load_backend_module(backend).FigureCanvas)
2042+
canvas_class=backend_registry.load_backend_module(backend).FigureCanvas
20442043
ifnothasattr(canvas_class,f"print_{fmt}"):
20452044
raiseValueError(
20462045
f"The{backend!r} backend does not support{fmt} output")

‎lib/matplotlib/backends/registry.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ def _backend_module_name(self, backend):
9898
backend=backend.lower()
9999

100100
# Check if have specific name to module mapping.
101-
backend=self._name_to_module.get(backend)orbackend
101+
backend=self._name_to_module.get(backend,backend)
102102

103103
return (backend[9:]ifbackend.startswith("module://")
104-
elsef"matplotlib.backends.backend_{backend.lower()}")
104+
elsef"matplotlib.backends.backend_{backend}")
105105

106106
def_clear(self):
107107
# Clear all dynamically-added data, used for testing only.
@@ -136,7 +136,7 @@ def _read_entry_points(self):
136136
ifsys.version_info>= (3,10):
137137
entry_points=im.entry_points(group=group)
138138
else:
139-
entry_points=im.entry_points().get(group,{})
139+
entry_points=im.entry_points().get(group,())
140140
entries= [(entry.name,entry.value)forentryinentry_points]
141141

142142
# For backward compatibility, if matplotlib-inline and/or ipympl are installed
@@ -199,7 +199,7 @@ def backend_for_gui_framework(self, framework):
199199
"""
200200
returnself._GUI_FRAMEWORK_TO_BACKEND.get(framework.lower())
201201

202-
defis_valid_backend(self,backend:str)->bool:
202+
defis_valid_backend(self,backend):
203203
"""
204204
Return True if the backend name is valid, False otherwise.
205205
@@ -262,7 +262,7 @@ def list_all(self):
262262
Backend names.
263263
"""
264264
self._ensure_entry_points_loaded()
265-
returnself.list_builtin()+list(self._backend_to_gui_framework.keys())
265+
return[*self.list_builtin(),*self._backend_to_gui_framework]
266266

267267
deflist_builtin(self,filter_=None):
268268
"""
@@ -286,19 +286,18 @@ def list_builtin(self, filter_=None):
286286
return [kfork,vinself._BUILTIN_BACKEND_TO_GUI_FRAMEWORK.items()
287287
ifv=="headless"]
288288

289-
returnlist(self._BUILTIN_BACKEND_TO_GUI_FRAMEWORK.keys())
289+
return[*self._BUILTIN_BACKEND_TO_GUI_FRAMEWORK]
290290

291291
deflist_gui_frameworks(self):
292292
"""
293-
Return list ofgui frameworks used by Matplotlib backends.
293+
Return list ofGUI frameworks used by Matplotlib backends.
294294
295295
Returns
296296
-------
297297
list of str
298298
GUI framework names.
299299
"""
300-
return [kforkinself._GUI_FRAMEWORK_TO_BACKEND.keys()
301-
ifk!="headless"]
300+
return [kforkinself._GUI_FRAMEWORK_TO_BACKENDifk!="headless"]
302301

303302
defload_backend_module(self,backend):
304303
"""
@@ -321,7 +320,7 @@ def resolve_backend(self, backend):
321320
"""
322321
Return the backend and GUI framework for the specified backend name.
323322
324-
If the GUI framework is not yet known then it will bedetermine by loading the
323+
If the GUI framework is not yet known then it will bedetermined by loading the
325324
backend module and checking the ``FigureCanvas.required_interactive_framework``
326325
attribute.
327326
@@ -351,8 +350,7 @@ def resolve_backend(self, backend):
351350
self._backend_to_gui_framework.get(backend))
352351

353352
# Is backend "module://something"?
354-
if (guiisNoneandisinstance(backend,str)and
355-
backend.startswith("module://")):
353+
ifguiisNoneandisinstance(backend,str)andbackend.startswith("module://"):
356354
gui="unknown"
357355

358356
# Is backend a possible entry point?
@@ -389,7 +387,7 @@ def resolve_gui_or_backend(self, gui_or_backend):
389387
390388
Returns
391389
-------
392-
Tuple ofbackend(str) and GUI framework (str or None).
390+
tuple of (str,str or None)
393391
A non-interactive backend returns None for its GUI framework rather than
394392
"headless".
395393
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp