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

Commitbc2e279

Browse files
authored
Merge pull request#160 from samcunliffe/guard-against-64
Test to guard against styling side-effects.
2 parents04383e0 +aede1f8 commitbc2e279

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

‎src/napari_matplotlib/tests/test_theme.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,33 @@ def test_titles_respect_theme(
8888

8989
assertax.xaxis.label.get_color()==expected_text_colour
9090
assertax.yaxis.label.get_color()==expected_text_colour
91+
92+
93+
@pytest.mark.mpl_image_compare
94+
deftest_no_theme_side_effects(make_napari_viewer):
95+
"""Ensure that napari-matplotlib doesn't pollute the globally set style.
96+
97+
A MWE to guard aganst issue matplotlib/#64. Should always reproduce a plot
98+
with the default matplotlib style.
99+
"""
100+
importmatplotlib.pyplotasplt
101+
102+
np.random.seed(12345)
103+
104+
# should not affect global matplotlib plot style
105+
viewer=make_napari_viewer()
106+
viewer.theme="dark"
107+
NapariMPLWidget(viewer)
108+
109+
# some plotting unrelated to napari-matplotlib
110+
normal_dist=np.random.normal(size=1000)
111+
unrelated_figure,ax=plt.subplots()
112+
ax.hist(normal_dist,bins=100)
113+
ax.set_xlabel("something unrelated to napari (x)")
114+
ax.set_ylabel("something unrelated to napari (y)")
115+
ax.set_title(
116+
"this plot style should not change with napari styles or themes"
117+
)
118+
unrelated_figure.tight_layout()
119+
120+
returnunrelated_figure

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp