8000 Use backend_registry for name of singleton instance · ianthomas23/matplotlib@acb7bf5 · GitHub
[go: up one dir, main page]

Skip to content

Commit acb7bf5

Browse files
committed
Use backend_registry for name of singleton instance
1 parent bffe0be commit acb7bf5

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ def _safe_pyplot_import():
105105
if current_framework is None:
106106
raise # No, something else went wrong, likely with the install...
107107

108-
from matplotlib.backends.registry import backendRegistry
109-
backend = backendRegistry.framework_to_backend(current_framework)
108+
from matplotlib.backends.registry import backend_registry
109+
backend = backend_registry.framework_to_backend(current_framework)
110110
if backend is None:
111111
raise KeyError(backend)
112112

lib/matplotlib/backends/registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ def list_builtin(self, filter_=None):
5858

5959

6060
# Singleton
61-
backendRegistry = BackendRegistry()
61+
backend_registry = BackendRegistry()

lib/matplotlib/backends/registry.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ class BackendRegistry:
1313
def list_builtin(self, filter_: BackendFilter | None) -> list[str]: ...
1414

1515

16-
backendRegistry: BackendRegistry
16+
backend_registry: BackendRegistry

lib/matplotlib/pyplot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def switch_backend(newbackend: str) -> None:
304304
current_framework = cbook._get_running_interactive_framework()
305305

306306
if (current_framework and
307-
(backend := backendRegistry.framework_to_backend(current_framework))):
307+
(backend := backend_registry.framework_to_backend(current_framework))):
308308
candidates = [backend]
309309
else:
310310
candidates = []
@@ -2505,7 +2505,7 @@ def polar(*args, **kwargs) -> list[Line2D]:
25052505
# is compatible with the current running interactive framework.
25062506
if (rcParams["backend_fallback"]
25072507
and rcParams._get_backend_or_none() in ( # type: ignore
2508-
set(backendRegistry.list_builtin(BackendFilter.INTERACTIVE_NON_WEB)))
2508+
set(backend_registry.list_builtin(BackendFilter.INTERACTIVE_NON_WEB)))
25092509
and cbook._get_running_interactive_framework()): # type: ignore
25102510
rcParams._set("backend", rcsetup._auto_backend_sentinel) # type: ignore
25112511

lib/matplotlib/rcsetup.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import numpy as np
2424

2525
from matplotlib import _api, cbook
26-
from matplotlib.backends.registry import BackendFilter, backendRegistry
26+
from matplotlib.backends.registry import BackendFilter, backend_registry
2727
from matplotlib.cbook import ls_mapper
2828
from matplotlib.colors import Colormap, is_color_like
2929
from matplotlib._fontconfig_pattern import parse_fontconfig_pattern
@@ -34,10 +34,10 @@
3434

3535

3636
# Deprecation of module-level attributes using PEP 562
37-
_deprecated_interactive_bk = backendRegistry.list_builtin(BackendFilter.INTERACTIVE)
38-
_deprecated_non_interactive_bk = backendRegistry.list_builtin(
37+
_deprecated_interactive_bk = backend_registry.list_builtin(BackendFilter.INTERACTIVE)
38+
_deprecated_non_interactive_bk = backend_registry.list_builtin(
3939
BackendFilter.NON_INTERACTIVE)
40-
_deprecated_all_backends = backendRegistry.list_builtin()
40+
_deprecated_all_backends = backend_registry.list_builtin()
4141

4242
_deprecated_names_and_args = {
4343
"interactive_bk": "matplotlib.backends.registry.BackendFilter.INTERACTIVE",
@@ -52,7 +52,7 @@ def __getattr__(name):
5252
_api.warn_deprecated(
5353
"3.9.0",
5454
name=name,
55-
alternative="``matplotlib.backends.registry.backendRegistry"
55+
alternative="``matplotlib.backends.registry.backend_registry"
5656
f".list_builtin({arg})``",
5757
)
5858
return globals()[f"_deprecated_{name}"]
@@ -271,7 +271,7 @@ def validate_fonttype(s):
271271

272272

273273
_validate_standard_backends = ValidateInStrings(
274-
'backend', backendRegistry.list_builtin(), ignorecase=True)
274+
'backend', backend_registry.list_builtin(), ignorecase=True)
275275
_auto_backend_sentinel = object()
276276

277277

lib/matplotlib/tests/test_backend_registry.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import pytest
55

6-
from matplotlib.backends.registry import BackendFilter, backendRegistry
6+
from matplotlib.backends.registry import BackendFilter, backend_registry
77

88

99
def has_duplicates(seq: Sequence[Any]) -> bool:
@@ -24,11 +24,11 @@ def has_duplicates(seq: Sequence[Any]) -> bool:
2424
]
2525
)
2626
d 10000 ef test_framework_to_backend(framework, expected):
27-
assert backendRegistry.framework_to_backend(framework) == expected
27+
assert backend_registry.framework_to_backend(framework) == expected
2828

2929

3030
def test_list_builtin():
31-
backends = backendRegistry.list_builtin()
31+
backends = backend_registry.list_builtin()
3232
assert not has_duplicates(backends)
3333
# Compare using sets as order is not important
3434
assert set(backends) == set((
@@ -53,7 +53,7 @@ def test_list_builtin():
5353
]
5454
)
5555
def test_list_builtin_with_filter(filter, expected):
56-
backends = backendRegistry.list_builtin(filter)
56+
backends = backend_registry.list_builtin(filter)
5757
assert not has_duplicates(backends)
5858
# Compare using sets as order is not important
5959
assert set(backends) == set(expected)

lib/matplotlib/tests/test_matplotlib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ def parse(key):
5757
backends += [e.strip() for e in line.split(',') if e]
5858
return backends
5959

60-
from matplotlib.backends.registry import BackendFilter, backendRegistry
60+
from matplotlib.backends.registry import BackendFilter, backend_registry
6161

6262
assert (set(parse('- interactive backends:\n')) ==
63-
set(backendRegistry.list_builtin(BackendFilter.INTERACTIVE)))
63+
set(backend_registry.list_builtin(BackendFilter.INTERACTIVE)))
6464
assert (set(parse('- non-interactive backends:\n')) ==
65-
set(backendRegistry.list_builtin(BackendFilter.NON_INTERACTIVE)))
65+
set(backend_registry.list_builtin(BackendFilter.NON_INTERACTIVE)))
6666

6767

6868
def test_importable_with__OO():

0 commit comments

Comments
 (0)
0