示例#1
0
def test_plot_signal_dim0():
    s = hs.signals.BaseSignal(np.arange(100)).T
    s.plot()
    assert s._plot.signal_plot is None
    assert s._plot.navigator_plot is not None
    s._plot.close()
    check_closing_plot(s)
示例#2
0
def test_close_figure(navigator, nav_dim, sig_dim):
    total_dim = nav_dim*sig_dim
    if sig_dim == 1:
        Signal = Signal1D
    elif sig_dim == 2:
        Signal = Signal2D
    s = Signal(np.arange(pow(10, total_dim)).reshape([10]*total_dim))
    s.plot(navigator=navigator)
    s._plot.close()
    check_closing_plot(s)

    if sig_dim == 1:
        m = s.create_model()
        m.plot()
        # Close with matplotlib event
        m._plot.signal_plot.figure.canvas.close_event()
        m.extend([Polynomial(1)])
示例#3
0
def test_plot_navigator_plot_signal(ndim):
    test_plot_nav1d = _TestPlot(ndim=ndim, sdim=1, data_type="real")
    s = test_plot_nav1d.signal
    navigator = -s.sum(-1).T
    s.plot(navigator=navigator)
    if ndim == 1:
        navigator_data = s._plot.navigator_plot.ax_lines[0]._get_data()
    else:
        navigator_data = s._plot.navigator_plot._current_data
    np.testing.assert_allclose(navigator_data, navigator.data)
    s._plot.close()
    check_closing_plot(s)

    s.plot(navigator=None)
    assert s._plot.signal_plot is not None
    assert s._plot.navigator_plot is None
    s._plot.close()
    check_closing_plot(s)
示例#4
0
def test_plot_slider(ndim, sdim):
    test_plot_nav1d = _TestPlot(ndim=ndim, sdim=sdim, data_type="real")
    s = test_plot_nav1d.signal
    # Plot twice to check that the args of the second call are used.
    s.plot()
    s.plot(navigator='slider')
    assert s._plot.signal_plot is not None
    assert s._plot.navigator_plot is None
    s._plot.close()
    check_closing_plot(s)

    if ndim > 1:
        s.plot(navigator='spectrum')
        assert s._plot.signal_plot is not None
        assert s._plot.navigator_plot is not None
        assert isinstance(s._plot.navigator_plot, Signal1DFigure)
        s._plot.close()
        check_closing_plot(s)
    if ndim > 2:
        s.plot()
        assert s._plot.signal_plot is not None
        assert s._plot.navigator_plot is not None
        assert len(s.axes_manager.events.indices_changed.connected) >= 2
        s._plot.close()
        check_closing_plot(s)
示例#5
0
def test_close_figure_with_plotted_marker():
    s = EDS_TEM_Spectrum()
    s.plot(True)
    s._plot.close()
    check_closing_plot(s)