Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
24 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
from glue.core.visual import VisualAttributes | ||
from matplotlib.cm import get_cmap | ||
|
||
import pytest | ||
|
||
def test_VA_preferred_cmap(): | ||
# Not a real CMAP array | ||
va = VisualAttributes(preferred_cmap=1) | ||
assert va.preferred_cmap == 1 | ||
# Not a real CMAP array - errors | ||
with pytest.raises(ValueError,match="`preferred_cmap` must be a string or an instance of a matplotlib.colors.Colormap"): | ||
VisualAttributes(preferred_cmap=1) | ||
|
||
# Not a valid string for a CMAP - errors | ||
with pytest.raises(ValueError,match="not_a_cmap is not a valid colormap name."): | ||
VisualAttributes(preferred_cmap="not_a_cmap") | ||
|
||
# Not a valid string for a CMAP | ||
va = VisualAttributes(preferred_cmap="not_a_cmap") | ||
assert va.preferred_cmap is None | ||
viridis_cmap = get_cmap("viridis") | ||
|
||
# get_cmap cmap name | ||
va = VisualAttributes(preferred_cmap="viridis") | ||
assert va.preferred_cmap == get_cmap("viridis") | ||
|
||
assert va.preferred_cmap == viridis_cmap | ||
# formal cmap name | ||
va = VisualAttributes(preferred_cmap="Viridis") | ||
assert va.preferred_cmap == get_cmap("viridis") | ||
assert va.preferred_cmap == viridis_cmap | ||
|
||
# Valid Colormap | ||
va = VisualAttributes(preferred_cmap=viridis_cmap) | ||
assert va.preferred_cmap == viridis_cmap | ||
|
||
# None is allowed - it is the default | ||
va = VisualAttributes(preferred_cmap=None) | ||
assert va.preferred_cmap == None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters