Skip to content

Commit

Permalink
Merge pull request #66 from pllim/cmap-method
Browse files Browse the repository at this point in the history
Expose methods for colormap
  • Loading branch information
mwcraig committed Mar 6, 2019
2 parents 3e206c9 + 79f8833 commit 038ee6e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
19 changes: 19 additions & 0 deletions astrowidgets/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,25 @@ def cuts(self, val):
raise ValueError('Value must have length 2.')
self._viewer.cut_levels(val[0], val[1])

@property
def colormap_options(self):
"""List of colormap names."""
from ginga import cmap
return cmap.get_names()

def set_colormap(self, cmap):
"""
Set colormap to the given colormap name.
Parameters
----------
cmap : str
Colormap name. Possible values can be obtained from
:meth:`colormap_options`.
"""
self._viewer.set_color_map(cmap)

@property
def cursor(self):
"""
Expand Down
9 changes: 9 additions & 0 deletions astrowidgets/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ def test_cuts():
assert image.cuts == (10, 100)


def test_colormap():
image = ImageWidget()
cmap_desired = 'gray'
cmap_list = image.colormap_options
assert len(cmap_list) > 0 and cmap_desired in cmap_list

image.set_colormap(cmap_desired)


def test_cursor():
image = ImageWidget()
assert image.cursor in ALLOWED_CURSOR_LOCATIONS
Expand Down

0 comments on commit 038ee6e

Please sign in to comment.