def test_resample_on_zoom(): # For images where the aspect ratio of pixels is fixed to be square, when # the user zooms in, the limits of the axes are actually changed twice by # matplotlib - a second time when the aspect ratio is enforced. So we need # to make sure that we update the modest_image when this is the case. session = simple_session() np.random.seed(12345) data = Data(x=np.random.random((2048, 2048)), label='image') session.data_collection.append(data) image = ImageViewer(session=session) image.add_data(data) image.show() try: device_ratio = image.axes.figure.canvas.devicePixelRatio() except AttributeError: device_ratio = 1. image.axes.figure.canvas.key_press_event('o') image.axes.figure.canvas.button_press_event(200 * device_ratio, 200 * device_ratio, 1) image.axes.figure.canvas.motion_notify_event(400 * device_ratio, 210 * device_ratio) image.axes.figure.canvas.button_release_event(400 * device_ratio, 210 * device_ratio, 1) return image.axes.figure
class BaseTestSpectrumTool: def setup_data(self): self.data = Data(x=np.zeros((3, 3, 3))) def setup_method(self, method): self.setup_data() session = simple_session() session.data_collection.append(self.data) self.image = ImageViewer(session) self.image.add_data(self.data) self.image.data = self.data self.image.attribute = self.data.id['x'] self.mode = self.image.toolbar.tools['spectrum'] self.tool = self.mode._tool self.tool.show = lambda *args: None def teardown_method(self, method): if self.image is not None: self.image.close() self.image = None if self.tool is not None: self.tool.close() self.tool = None