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

Commit3528dac

Browse files
committed
Add theme test
1 parentabd00bd commit3528dac

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed
Loading

‎src/napari_matplotlib/tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
importos
2+
frompathlibimportPath
23

34
importnumpyasnp
45
importpytest
@@ -52,3 +53,8 @@ def set_strict_qt():
5253
os.environ[env_var]=old_val
5354
else:
5455
delos.environ[env_var]
56+
57+
58+
@pytest.fixture
59+
deftheme_path():
60+
returnPath(__file__).parent/"data"/"test_theme.mplstyle"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Dark-theme napari colour scheme for matplotlib plots
2+
3+
#f4b8b2 # light red
4+
#b2e4f4 # light blue
5+
#0aa3fc # dark blue
6+
#008939 # dark green
7+
8+
figure.facecolor : f4b8b2 # light red
9+
axes.facecolor : b2e4f4 # light blue
10+
axes.edgecolor : 0aa3fc # dark blue
11+
12+
xtick.color : 008939 # dark green
13+
xtick.labelcolor : 008939 # dark green
14+
ytick.color : 008939 # dark green
15+
ytick.labelcolor : 008939 # dark green

‎src/napari_matplotlib/tests/test_theme.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromcopyimportdeepcopy
2+
13
importnapari
24
importnumpyasnp
35
importpytest
@@ -118,3 +120,23 @@ def test_no_theme_side_effects(make_napari_viewer):
118120
unrelated_figure.tight_layout()
119121

120122
returnunrelated_figure
123+
124+
125+
@pytest.mark.mpl_image_compare
126+
deftest_custom_theme(make_napari_viewer,theme_path,brain_data):
127+
viewer=make_napari_viewer()
128+
viewer.theme="dark"
129+
130+
widget=ScatterWidget(viewer)
131+
widget.mpl_style_sheet_path=theme_path
132+
133+
viewer.add_image(brain_data[0],**brain_data[1],name="brain")
134+
viewer.add_image(
135+
brain_data[0]*-1,**brain_data[1],name="brain_reversed"
136+
)
137+
138+
viewer.layers.selection.clear()
139+
viewer.layers.selection.add(viewer.layers[0])
140+
viewer.layers.selection.add(viewer.layers[1])
141+
142+
returndeepcopy(widget.figure)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp