def test_raster_invert_axes(self): arr = np.array([[0, 1, 2], [3, 4, 5]]) raster = Raster(arr).opts(invert_axes=True) plot = mpl_renderer.get_plot(raster) artist = plot.handles['artist'] self.assertEqual(artist.get_array().data, arr.T[::-1]) self.assertEqual(artist.get_extent(), [0, 2, 0, 3])
def test_raster_nodata_uint(self): arr = np.array([[0, 1, 2], [3, 4, 5]], dtype='uint32') expected = np.array([[3, 4, 5], [np.NaN, 1, 2]]) raster = Raster(arr).opts(nodata=0) plot = mpl_renderer.get_plot(raster) artist = plot.handles['artist'] self.assertEqual(artist.get_array().data, expected)
def test_raster_invert_axes(self): arr = np.array([[0, 1, 2], [3, 4, 5]]) raster = Raster(arr).opts(plot=dict(invert_axes=True)) plot = bokeh_renderer.get_plot(raster) source = plot.handles['source'] self.assertEqual(source.data['image'][0], np.rot90(arr)) self.assertEqual(source.data['x'][0], 0) self.assertEqual(source.data['y'][0], 3) self.assertEqual(source.data['dw'][0], 2) self.assertEqual(source.data['dh'][0], -3)
def test_raster_range_masked(self): arr = np.random.rand(10,10)-0.5 arr = np.ma.masked_where(arr<=0, arr) rrange = Raster(arr).range(2) self.assertEqual(rrange, (np.min(arr), np.max(arr)))
def test_raster_sample(self): raster = Raster(self.array1) self.assertEqual(raster.sample(y=0), Curve(np.array([(0, 0), (1, 1), (2, 2)]), kdims=['x'], vdims=['z']))
def test_raster_index(self): raster = Raster(self.array1) self.assertEqual(raster[0, 1], 3)
def test_raster_init(self): Raster(self.array1)
def test_raster_sample(self): raster = Raster(self.array1) self.assertEqual(raster.sample(y=0).data, np.array([(0, 0), (1, 1), (2, 2)]))