def test_record_parameters_in_metadata(self): imgs = Images(np.asarray([1])) imgs.record_operation('test_func', 'A pretty name', this=765, that=495.0, roi=(1, 2, 3, 4)) expected = { 'operation_history': [{ 'name': 'test_func', 'display_name': 'A pretty name', 'kwargs': { 'this': 765, 'that': 495.0, 'roi': (1, 2, 3, 4) }, }] } self.assertIn(const.TIMESTAMP, imgs.metadata[const.OPERATION_HISTORY][0]) imgs.metadata[const.OPERATION_HISTORY][0].pop(const.TIMESTAMP) self.assertEqual(imgs.metadata, expected)
def update_image_operations(images: Images, model): """ TODO: remove this function / integrate in recon GUI Updates the image operation history with the results in the given model. """ images.record_operation(const.OPERATION_NAME_COR_TILT_FINDING, display_name="Calculated COR/Tilt", **model.stack_properties)
def test_do_stack_reconstruct_slice(self): test_data = Images(np.ndarray(shape=(200, 250), dtype=np.float32)) test_data.record_operation = mock.Mock() task_mock = mock.Mock(result=test_data, error=None) self.presenter._get_slice_index = mock.Mock(return_value=7) self.presenter._on_stack_reconstruct_slice_done(task_mock) self.view.show_recon_volume.assert_called_once() np.array_equal(self.view.show_recon_volume.call_args[0][0].data, test_data) test_data.record_operation.assert_called_once_with('AstraRecon.single_sino', 'Slice Reconstruction', slice_idx=7, **self.view.recon_params().to_dict())