def test_colour(self): colours = ['#ff0000', '#00ff00'] self.fig, self.ax = one_colourbar() self.ax, self.cbar = heatmap.add_heatmap(self.ax, self.x, self.y, self.c, xinterp=5, yinterp=5, colour=colours)
def test_colourmap(self): cmap = mpl.cm.get_cmap('viridis') self.fig, self.ax = one_colourbar() self.ax, self.cbar = heatmap.add_heatmap(self.ax, self.x, self.y, self.c, xinterp=5, yinterp=5, colour=cmap)
def setUpClass(cls): cls.x = [2, 4, 6] cls.y = [4, 8, 12] cls.c = [[2, 4, 6], [6, 8, 10], [10, 12, 14]] cls.fig, cls.ax = one_colourbar() cls.ax, cls.cbar = heatmap.add_heatmap(cls.ax, cls.x, cls.y, cls.c, xinterp=5, yinterp=5)
def test_default(self, mock_colourbar): cbar = heatmap.add_heatmap(self.ax, self.x, self.y, self.c, xinterp=None, yinterp=None, xscale='linear', yscale='linear', cscale='linear') self.ax.pcolormesh.assert_called_once() self.ax.set_xscale.assert_called_once_with('linear') self.ax.set_yscale.assert_called_once_with('linear') self.ax.set_xlim.assert_called_once_with(1, 4) self.ax.set_ylim.assert_called_once_with(2, 8) mock_colourbar.assert_called_once() cbar.ax.set_yscale.assert_called_once_with('linear')
def test_interpolate(self, mock_colourbar): cbar = heatmap.add_heatmap(self.ax, self.x, self.y, self.c, xinterp=5, yinterp=5, kind='linear', xscale='linear', yscale='linear', cscale='linear') self.ax.pcolormesh.assert_called_once() self.ax.set_xscale.assert_called_once_with('linear') self.ax.set_yscale.assert_called_once_with('linear') self.ax.set_xlim.assert_called_once_with(1, 3.5) self.ax.set_ylim.assert_called_once_with(2, 7) mock_colourbar.assert_called_once() cbar.ax.set_yscale.assert_called_once_with('linear')
def setUpClass(cls): cls.x = [1e2, 1e4, 1e6] cls.y = [1e4, 1e8, 1e12] cls.c = [[1e2, 1e4, 1e6], [1e6, 1e8, 1e10], [1e10, 1e12, 1e14]] cls.fig, cls.ax = one_colourbar() cls.ax, cls.cbar = heatmap.add_heatmap(cls.ax, cls.x, cls.y, cls.c, xscale='log', yscale='log', cscale='log', xinterp=5, yinterp=5)
def test_log(self, mock_colourbar): self.x = np.power(10, self.x) self.y = np.power(10, self.y) self.c = np.power(10, self.c) cbar = heatmap.add_heatmap(self.ax, self.x, self.y, self.c, xinterp=None, yinterp=None, xscale='log', yscale='log', cscale='log') self.ax.pcolormesh.assert_called_once() self.ax.set_xscale.assert_called_once_with('log') self.ax.set_yscale.assert_called_once_with('log') self.ax.set_xlim.assert_called_once_with(1e1, 1e4) self.ax.set_ylim.assert_called_once_with(1e2, 1e8) mock_colourbar.assert_called_once() cbar.ax.set_yscale.assert_called_once_with('log')
def setUpClass(cls): cls.x = [1, 2, 3, 4] cls.y = [2, 4, 6, 8] cls.c = [[1, 2, 3], [2, 4, 6], [3, 6, 9]] cls.fig, cls.ax = one_colourbar() cls.ax, cls.cbar = heatmap.add_heatmap(cls.ax, cls.x, cls.y, cls.c)