Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Apr 21, 2024
1 parent af49a83 commit 703d68b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/nd2/_ome.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def nd2_ome_metadata(
rdr = cast("ModernReader", f._rdr)
meta = f.metadata
images = []
acquisition_date = rdr._acquisition_date()
acquisition_date = rdr._acquisition_datetime()
uuid_ = f"urn:uuid:{uuid.uuid4()}"
sizes = dict(f.sizes)
n_positions = sizes.pop(AXIS.POSITION, 1)
Expand Down
9 changes: 6 additions & 3 deletions src/nd2/readers/_modern/modern_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import warnings
import zlib
from contextlib import suppress
from typing import TYPE_CHECKING, Any, Iterable, Mapping, Sequence, cast

import numpy as np
Expand Down Expand Up @@ -528,11 +529,13 @@ def _app_info(self) -> dict:
k = b"CustomDataVar|AppInfo_V1_0!"
return self._decode_chunk(k) if k in self.chunkmap else {}

def _acquisition_date(self) -> datetime.datetime | None:
def _acquisition_datetime(self) -> datetime.datetime | None:
"""Try to extract acquisition date."""
time = self._cached_global_metadata().get("time", {})
jdn = time.get("absoluteJulianDayNumber")
return _util.jdn_to_datetime(jdn) if jdn else None
if jdn := time.get("absoluteJulianDayNumber"):
with suppress(ValueError):
return _util.jdn_to_datetime(jdn)
return None

def binary_data(self) -> BinaryLayers | None:
from nd2._binary import BinaryLayer, BinaryLayers, decode_binary_mask
Expand Down

0 comments on commit 703d68b

Please sign in to comment.