Skip to content

Commit 34afcd3

Browse files
committed
Remove colormap_options
1 parent e7fec85 commit 34afcd3

File tree

3 files changed

+5
-57
lines changed

3 files changed

+5
-57
lines changed

src/astro_image_display_api/dummy_viewer.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ class ImageViewer:
5959
# Allowed locations for cursor display
6060
ALLOWED_CURSOR_LOCATIONS: tuple = ImageViewerInterface.ALLOWED_CURSOR_LOCATIONS
6161

62-
# Minimal required colormaps
63-
MINIMUM_REQUIRED_COLORMAPS: tuple[str, ...] = ImageViewerInterface.MINIMUM_REQUIRED_COLORMAPS
64-
6562
# some internal variable for keeping track of viewer state
6663
_wcs: WCS | None = None
6764
_center: tuple[numbers.Real, numbers.Real] = (0.0, 0.0)
@@ -154,15 +151,7 @@ def set_cuts(self, value: tuple[numbers.Real, numbers.Real] | BaseInterval, imag
154151
raise ValueError(f"Image label '{image_label}' not found. Please load an image first.")
155152
self._images[image_label].cuts = self._cuts
156153

157-
@property
158-
def colormap_options(self) -> list[str]:
159-
return list(self.MINIMUM_REQUIRED_COLORMAPS)
160-
colormap_options.__doc__ = ImageViewerInterface.colormap_options.__doc__
161-
162154
def set_colormap(self, map_name: str, image_label: str | None = None) -> None:
163-
if map_name.lower() not in self.colormap_options:
164-
raise ValueError(f"Invalid colormap '{map_name}'. Must be one of {self.colormap_options}.")
165-
166155
image_label = self._resolve_image_label(image_label)
167156
if image_label not in self._images:
168157
raise ValueError(f"Image label '{image_label}' not found. Please load an image first.")

src/astro_image_display_api/interface_definition.py

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,13 @@
33
import os
44

55
from astropy.coordinates import SkyCoord
6-
from astropy.nddata import NDData
76
from astropy.table import Table
87
from astropy.units import Quantity
98
from astropy.visualization import BaseInterval, BaseStretch
109

11-
from numpy.typing import ArrayLike
1210

1311
# Allowed locations for cursor display
1412
ALLOWED_CURSOR_LOCATIONS = ('top', 'bottom', None)
15-
MINIMUM_REQUIRED_COLORMAPS = (
16-
'gray',
17-
'viridis',
18-
'plasma',
19-
'inferno',
20-
'magma',
21-
'purple-blue',
22-
'yellow-green-blue',
23-
'yellow-orange-red',
24-
'red-purple',
25-
'blue-green',
26-
'hot',
27-
'red-blue',
28-
'red-yellow-blue',
29-
'purple-orange',
30-
'purple-green',
31-
)
3213

3314
__all__ = [
3415
'ImageViewerInterface',
@@ -47,9 +28,6 @@ class ImageViewerInterface(Protocol):
4728
# Allowed locations for cursor display
4829
ALLOWED_CURSOR_LOCATIONS: tuple = ALLOWED_CURSOR_LOCATIONS
4930

50-
# Required colormaps for the viewer
51-
MINIMUM_REQUIRED_COLORMAPS: tuple[str, ...] = MINIMUM_REQUIRED_COLORMAPS
52-
5331
# The methods, grouped loosely by purpose
5432

5533
# Method for loading image data
@@ -157,10 +135,10 @@ def set_colormap(self, map_name: str, image_label: str | None = None) -> None:
157135
Parameters
158136
----------
159137
map_name : str
160-
The name of the colormap to set. This should be a valid
161-
colormap name from Matplotlib; not all backends will support
138+
The name of the colormap to set. This should be a
139+
valid colormap name from Matplotlib`_;
140+
not all backends will support
162141
all colormaps, so the viewer should handle errors gracefully.
163-
The case of the `map_name` is not important.
164142
image_label : str, optional
165143
The label of the image to set the colormap for. If not given and there is
166144
only one image loaded, the colormap for that image is set. If there are
@@ -171,6 +149,8 @@ def set_colormap(self, map_name: str, image_label: str | None = None) -> None:
171149
ValueError
172150
If the `map_name` is not a valid colormap name or if the `image_label`
173151
is not provided when there are multiple images loaded.
152+
153+
.. _Matplotlib: https://matplotlib.org/stable/gallery/color/colormap_reference.html
174154
"""
175155
raise NotImplementedError
176156

@@ -199,19 +179,6 @@ def get_colormap(self, image_label: str | None = None) -> str:
199179
"""
200180
raise NotImplementedError
201181

202-
@property
203-
@abstractmethod
204-
def colormap_options(self) -> list[str]:
205-
"""
206-
Get the list of available colormaps.
207-
208-
Returns
209-
-------
210-
list of str
211-
A list of available colormap names.
212-
"""
213-
raise NotImplementedError
214-
215182
# Saving contents of the view and accessing the view
216183
@abstractmethod
217184
def save(self, filename: str | os.PathLike, overwrite: bool = False) -> None:

src/astro_image_display_api/widget_api_test.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -718,11 +718,6 @@ def test_stretch_cuts_errors(self, data):
718718
with pytest.raises(ValueError, match='[Ii]mage label.*not found'):
719719
self.image.set_cuts((10, 100), image_label='not a valid label')
720720

721-
def test_colormap_options(self):
722-
cmap_list = self.image.colormap_options
723-
assert set(ImageViewerInterface.MINIMUM_REQUIRED_COLORMAPS) <= set(cmap_list)
724-
assert set(self.image.MINIMUM_REQUIRED_COLORMAPS) == set(ImageViewerInterface.MINIMUM_REQUIRED_COLORMAPS)
725-
726721
def test_set_get_colormap(self, data):
727722
# Check setting and getting with a single image label.
728723
self.image.load_image(data, image_label='test')
@@ -753,9 +748,6 @@ def test_set_colormap_errors(self, data):
753748
# is not in the list of allowed colormaps.
754749
self.image.load_image(data, image_label='test')
755750

756-
with pytest.raises(ValueError, match='[Ii]nvalid colormap'):
757-
self.image.set_colormap('not a valid colormap')
758-
759751
# Check that getting a colormap for an image label that does not exist
760752
with pytest.raises(ValueError, match='[Ii]mage label.*not found'):
761753
self.image.get_colormap(image_label='not a valid label')

0 commit comments

Comments
 (0)