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

Appearance settings

Commit bbeb742

Browse filesBrowse files
committed
Remove isinstance() calls in mpl.styles.use().
1 parent 4621942 commit bbeb742
Copy full SHA for bbeb742

File tree

Expand file treeCollapse file tree

1 file changed

+19
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-14
lines changed

‎lib/matplotlib/style/core.py

Copy file name to clipboardExpand all lines: lib/matplotlib/style/core.py
+19-14Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import matplotlib as mpl
2323
from matplotlib import cbook
24-
from matplotlib import rc_params_from_file, RcParams
24+
from matplotlib import rc_params_from_file
2525

2626

2727
__all__ = ['use', 'context', 'available', 'library', 'reload_library']
@@ -44,19 +44,23 @@ def use(name):
4444
4545
Parameters
4646
----------
47-
name : str, list of str, or RcParams
48-
Name of style or path/URL to a style file. For a list of available
49-
style names, see `style.available`. If given a list, each style is
50-
applied from first to last in the list. Instead of strings, each style
51-
may also be specified directly as an instance of `RcParams`.
47+
name : str, dict, list of str and/or dict
48+
If `name` is a str, then it is the name of a style or a path/URL to a
49+
style file. For a list of available style names, see `style.available`.
50+
If `name` is a dict, then it contains valid rc key/value pairs. If
51+
`name` is a list of styles, then each style (str or dict) is applied
52+
from first to last in the list.
5253
"""
53-
if cbook.is_string_like(name) or isinstance(name, RcParams):
54+
# If name is a single str or dict, make it a single element list.
55+
if cbook.is_string_like(name) or hasattr(name, 'keys'):
5456
name = [name]
5557

5658
for style in name:
57-
if isinstance(style, RcParams):
59+
if not cbook.is_string_like(name):
5860
mpl.rcParams.update(style)
59-
elif style in library:
61+
continue
62+
63+
if style in library:
6064
mpl.rcParams.update(library[style])
6165
else:
6266
try:
@@ -75,11 +79,12 @@ def context(name, after_reset=False):
7579
7680
Parameters
7781
----------
78-
name : str, list of str, or RcParams
79-
Name of style or path/URL to a style file. For a list of available
80-
style names, see `style.available`. If given a list, each style is
81-
applied from first to last in the list. Instead of strings, each style
82-
may also be specified directly as an instance of `RcParams`.
82+
name : str, dict, list of str and/or dict
83+
If `name` is a str, then it is the name of a style or a path/URL to a
84+
style file. For a list of available style names, see `style.available`.
85+
If `name` is a dict, then it contains valid rc key/value pairs. If
86+
`name` is a list of styles, then each style (str or dict) is applied
87+
from first to last in the list.
8388
after_reset : bool
8489
If True, apply style after resetting settings to their defaults;
8590
otherwise, apply style on top of the current settings.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.