Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
 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()