def test_reset_span_selector(self): s = self.s s.plot(vmin='10th', vmax='99th') ceditor = ImageContrastEditor(s._plot.signal_plot) ceditor.span_selector.set_initial((20, 90)) try: ceditor.update_span_selector() ax_image = s._plot.signal_plot.ax.images[0] np.testing.assert_allclose(ax_image.norm.vmin, 20) np.testing.assert_allclose(ax_image.norm.vmax, 90) ceditor._reset_span_selector() np.testing.assert_allclose(ax_image.norm.vmin, 9.9) np.testing.assert_allclose(ax_image.norm.vmax, 98.01) except TypeError as e: # Failure sometimes seen with pytest-xdist (parallel tests) # Message: `TypeError: restore_region() argument 1 must be matplotlib.backends._backend_agg.BufferRegion, not None` # See e.g. https://github.com/hyperspy/hyperspy/issues/1688 # for a similar issue. Currently unclear what solution is. pytest.skip(f"Skipping reset_span_selector test due to {e}")
def test_reset_span_selector(self): s = self.s s.plot(vmin='10th', vmax='99th') ceditor = ImageContrastEditor(s._plot.signal_plot) ceditor.span_selector.set_initial((20, 90)) ceditor.update_span_selector() ax_image = s._plot.signal_plot.ax.images[0] assert_allclose(ax_image.norm.vmin, 20) assert_allclose(ax_image.norm.vmax, 90) ceditor._reset_span_selector() assert_allclose(ax_image.norm.vmin, 9.9) assert_allclose(ax_image.norm.vmax, 98.01)