def test_plot_constrast_editor_reset(): np.random.seed(1) data = np.random.random(size=(100, 100)) * 1000 data += np.arange(100 * 100).reshape((100, 100)) s = signals.Signal2D(data) s.plot() ceditor = ImageContrastEditor(s._plot.signal_plot) ceditor.span_selector.extents = (3E3, 5E3) ceditor._update_image_contrast() vmin, vmax = 2.1143748173448866, 10988.568946171192 np.testing.assert_allclose(ceditor._vmin, vmin) np.testing.assert_allclose(ceditor._vmax, vmax) np.testing.assert_allclose(ceditor._get_current_range(), (3E3, 5E3)) ceditor.reset() assert not ceditor.span_selector.visible assert not ceditor._is_selector_visible np.testing.assert_allclose(ceditor._get_current_range(), (vmin, vmax)) np.testing.assert_allclose(ceditor.image._vmin, vmin) np.testing.assert_allclose(ceditor.image._vmax, vmax)
def test_plot_constrast_editor_auto_indices_changed(): np.random.seed(1) data = np.random.random(size=(10, 10, 100, 100)) * 1000 data += np.arange(10 * 10 * 100 * 100).reshape((10, 10, 100, 100)) s = signals.Signal2D(data) s.plot() ceditor = ImageContrastEditor(s._plot.signal_plot) ceditor.span_selector.extents = (3E3, 5E3) ceditor.update_span_selector_traits() s.axes_manager.indices = (0, 1) # auto is None by default, the span selector need to be removed: assert not ceditor.span_selector.visible assert not ceditor._is_selector_visible ref_value = (100045.29840954322, 110988.10581608873) np.testing.assert_allclose(ceditor._get_current_range(), ref_value) # Change auto to False ceditor.auto = False s.axes_manager.indices = (0, 2) # vmin, vmax shouldn't have changed np.testing.assert_allclose(ceditor._get_current_range(), ref_value)