Skip to content

Commit

Permalink
fix metadata return logic, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyakolb committed Oct 25, 2024
1 parent eb467b4 commit cecf6e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pycromanager/acquisition/acq_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,20 @@ def await_image_saved(self, axes=None, return_image=True, return_metadata=False)
while not self._notification_recieved[key][AcqNotification.Image.IMAGE_SAVED]:
self._condition.wait()

if return_image:
if return_image and return_metadata:
if isinstance(axes, list):
return [(self._acq.get_dataset().read_image(**ax), self._acq.get_dataset().read_metadata(**ax)) for ax in axes]
else:
return self._acq.get_dataset().read_image(**axes), self._acq.get_dataset().read_metadata(**axes)
elif return_image:
if isinstance(axes, list):
return [self._acq.get_dataset().read_image(**ax) for ax in axes]
else:
return self._acq.get_dataset().read_image(**axes)
if return_metadata:
elif return_metadata:
if isinstance(axes, list):
return [self._acq.get_dataset().read_metadata(**ax) for ax in axes]
else:
return self._acq.get_dataset().read_metadata(**axes)
if return_image and return_metadata:
if isinstance(axes, list):
return [(self._acq.get_dataset().read_image(**ax), self._acq.get_dataset().read_metadata(**ax)) for ax in axes]
else:
return self._acq.get_dataset().read_image(**axes), self._acq.get_dataset().read_metadata(**axes)


8 changes: 8 additions & 0 deletions pycromanager/test/test_notifications_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def test_async_image_read(launch_mm_headless, setup_data_folder):
assert np.all(image == acq.get_dataset().read_image(time=5))
acq.get_dataset().close()

def test_async_image_read_metadata_return(launch_mm_headless, setup_data_folder):
events = multi_d_acquisition_events(num_time_points=10, time_interval_s=0.5)
with Acquisition(directory=setup_data_folder, name='test_async_image_read', show_display=False) as acq:
future = acq.acquire(events)
_, metadata = future.await_image_saved({'time': 5}, return_image=True, return_metadata=True)
assert isinstance(metadata, dict)
acq.get_dataset().close()

def test_async_image_read_sequence(launch_mm_headless, setup_data_folder):
events = multi_d_acquisition_events(num_time_points=10, time_interval_s=0)
with Acquisition(directory=setup_data_folder, name='test_async_image_read_sequence', show_display=False) as acq:
Expand Down

0 comments on commit cecf6e2

Please sign in to comment.