8000 Merge pull request #25268 from fjosw/fix/local_style · matplotlib/matplotlib@ee7d75e · GitHub
[go: up one dir, main page]

Skip to content

Commit ee7d75e

Browse files
authored
Merge pull request #25268 from fjosw/fix/local_style
Fix import of styles with relative path
2 parents f726d2c + e92a8cf commit ee7d75e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/matplotlib/style/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def use(style):
153153
path = (importlib_resources.files(pkg)
154154
/ f"{name}.{STYLE_EXTENSION}")
155155
style = _rc_params_in_file(path)
156-
except (ModuleNotFoundError, OSError) as exc:
156+
except (ModuleNotFoundError, OSError, TypeError) as exc:
157157
# There is an ambiguity whether a dotted name refers to a
158158
# package.style_name or to a dotted file path. Currently,
159159
# we silently try the first form and then the second one;

lib/matplotlib/tests/test_style.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,5 @@ def test_style_from_module(tmp_path, monkeypatch):
205205
assert mpl.rcParams["lines.linewidth"] == 42
206206
mpl.style.use("mpl_test_style_pkg.mplstyle")
207207
assert mpl.rcParams["lines.linewidth"] == 84
208+
mpl.style.use("./mpl_test_style_pkg.mplstyle")
209+
assert mpl.rcParams["lines.linewidth"] == 84

0 commit comments

Comments
 (0)
0