Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cmap/_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def to_napari(cm: Colormap) -> NapariColormap:
if "nan_color" in param_names and cm.bad_color is not None:
kwargs["nan_color"] = cm.bad_color.rgba
if "high_color" in param_names and cm.over_color is not None:
kwargs["nan_color"] = cm.over_color.rgba
kwargs["high_color"] = cm.over_color.rgba
if "low_color" in param_names and cm.under_color is not None:
kwargs["low_color"] = cm.under_color.rgba
return Colormap(**kwargs)
Expand Down
13 changes: 13 additions & 0 deletions tests/test_third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ def test_napari(qapp: "QApplication") -> None:
v.close()


@pytest.mark.filterwarnings("ignore")
def test_napari_extreme_colors() -> None:
# nan_color/low_color/high_color were added in napari 0.6.1
pytest.importorskip("napari", minversion="0.6.1")

bad = "yellow"
ncm = Colormap(["black", "white"], under=UNDER, over=OVER, bad=bad).to_napari()

np.testing.assert_allclose(ncm.low_color, Color(UNDER).rgba)
np.testing.assert_allclose(ncm.high_color, Color(OVER).rgba)
np.testing.assert_allclose(ncm.nan_color, Color(bad).rgba)


@pytest.mark.skipif(
sys.platform == "darwin" and sys.version_info >= (3, 13),
reason="not yet working upstream",
Expand Down
Loading