def test_plot_one_axis(self): w = Window(window="gaussian", shape=(5, ), std=2) fig, im, cbar = w.plot() # Compare to global window GAUSS5_STD2 np.testing.assert_array_almost_equal(w, GAUSS5_STD2) np.testing.assert_array_almost_equal(im.get_array().data[:, 0], GAUSS5_STD2)
def test_plot_default_values(self): w = Window() fig, im, cbar = w.plot() np.testing.assert_array_almost_equal(w, im.get_array().data) assert im.cmap.name == "viridis" assert isinstance(fig, Figure) assert isinstance(im, AxesImage) assert isinstance(cbar, Colorbar)
def test_plot(self, window, answer_coeff, cmap, textcolors, cmap_label, tmp_path): w = Window(window=window) fig, im, cbar = w.plot(cmap=cmap, textcolors=textcolors, cmap_label=cmap_label) np.testing.assert_array_almost_equal(w, answer_coeff) np.testing.assert_array_almost_equal(im.get_array().data, answer_coeff) assert isinstance(fig, Figure) assert isinstance(im, AxesImage) assert isinstance(cbar, Colorbar) # Check that the figure can be written to and read from file os.chdir(tmp_path) fname = "tests.png" fig.savefig(fname) _ = imread(fname)
def test_plot_invalid_window(self): w = Window() w.name = 1 assert w.is_valid() is False with pytest.raises(ValueError, match="Window is invalid."): w.plot()