diff --git a/hyperspy/_signals/lazy.py b/hyperspy/_signals/lazy.py index 908f76af4c..ecab8c00a2 100644 --- a/hyperspy/_signals/lazy.py +++ b/hyperspy/_signals/lazy.py @@ -1102,6 +1102,8 @@ def post(a): print("\n".join([str(pr) for pr in to_print])) def plot(self, navigator='auto', **kwargs): + if self.axes_manager.ragged: + raise RuntimeError("Plotting ragged signal is not supported.") if isinstance(navigator, str): if navigator == 'spectrum': # We don't support the 'spectrum' option to keep it simple diff --git a/hyperspy/tests/drawing/test_plot_signal.py b/hyperspy/tests/drawing/test_plot_signal.py index 5f1dcd2e66..ee308dc23e 100644 --- a/hyperspy/tests/drawing/test_plot_signal.py +++ b/hyperspy/tests/drawing/test_plot_signal.py @@ -333,10 +333,13 @@ def test_plot_signal_scalar(): assert s._plot is None -def test_plot_ragged_array(): +@pytest.mark.parametrize('lazy', [True, False]) +def test_plot_ragged_array(lazy): data = np.empty((2, 5), dtype=object) data.fill(np.array([10, 20])) s = hs.signals.BaseSignal(data, ragged=True) + if lazy: + s = s.as_lazy() with pytest.raises(RuntimeError): s.plot()