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
6 changes: 3 additions & 3 deletions src/cmap/_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def to_plotly(cm: Colormap) -> list[list[float | str]]:
def _napari_colormap_param_names() -> set[str]:
from napari.utils.colormaps import Colormap

if hasattr(Colormap, "__fields__"):
return set(Colormap.__fields__)
elif hasattr(Colormap, "model_fields"):
if hasattr(Colormap, "model_fields"):
return set(Colormap.model_fields)
elif hasattr(Colormap, "__fields__"):
return set(Colormap.__fields__)
return set()


Expand Down
9 changes: 9 additions & 0 deletions tests/test_third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ def test_napari(qapp: "QApplication") -> None:
v.close()


def test_napari_no_deprecated_field_access() -> None:
pytest.importorskip("napari")
from cmap._external import _napari_colormap_param_names

# the names are cached, so an earlier conversion may already have paid the warning
_napari_colormap_param_names.cache_clear()
assert CMAP.to_napari() is not None


@pytest.mark.filterwarnings("ignore")
def test_napari_extreme_colors() -> None:
# nan_color/low_color/high_color were added in napari 0.6.1
Expand Down
Loading