-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
1 parent
74121fe
commit d0e75c2
Showing
2 changed files
with
63 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import numpy as np | ||
|
||
from holoviews.element import Image | ||
|
||
from .testplot import TestMPLPlot, mpl_renderer | ||
|
||
|
||
class TestColorbarPlot(TestMPLPlot): | ||
|
||
def test_colormapper_symmetric(self): | ||
img = Image(np.array([[0, 1], [2, 3]])).options(symmetric=True) | ||
plot = mpl_renderer.get_plot(img) | ||
artist = plot.handles['artist'] | ||
self.assertEqual(artist.get_clim(), (-3, 3)) | ||
|
||
def test_colormapper_color_levels(self): | ||
img = Image(np.array([[0, 1], [2, 3]])).options(color_levels=5) | ||
plot = mpl_renderer.get_plot(img) | ||
artist = plot.handles['artist'] | ||
self.assertEqual(len(artist.cmap.colors), 5) | ||
|
||
def test_colormapper_transparent_nan(self): | ||
img = Image(np.array([[0, 1], [2, 3]])).options(clipping_colors={'NaN': 'transparent'}) | ||
plot = mpl_renderer.get_plot(img) | ||
cmap = plot.handles['artist'].cmap | ||
self.assertEqual(cmap._rgba_bad, (1.0, 1.0, 1.0, 0)) | ||
|
||
def test_colormapper_min_max_colors(self): | ||
img = Image(np.array([[0, 1], [2, 3]])).options(clipping_colors={'min': 'red', 'max': 'blue'}) | ||
plot = mpl_renderer.get_plot(img) | ||
cmap = plot.handles['artist'].cmap | ||
print(dir(cmap)) | ||
self.assertEqual(cmap._rgba_under, (1.0, 0, 0, 1)) | ||
self.assertEqual(cmap._rgba_over, (0, 0, 1.0, 1)) |