Skip to content

Commit

Permalink
fix issue Rohde-Schwarz#22: add getter/setter for date
Browse files Browse the repository at this point in the history
  • Loading branch information
mauruns committed May 30, 2024
1 parent e0d7163 commit 0b685d5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/RsWaveform/meta/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"peak": None,
"samples": None,
"reflevel": None,
"date": None,
}

META_IQTAR_DEFAULTS = {
Expand Down
11 changes: 10 additions & 1 deletion src/RsWaveform/meta/meta_wv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""WV meta data for Storage container."""

import datetime
import typing

import numpy as np
Expand Down Expand Up @@ -115,3 +115,12 @@ def reflevel(self) -> typing.Optional[float]:
@reflevel.setter
def reflevel(self, value: float) -> None:
self._items["reflevel"] = value

@property
def date(self) -> typing.Optional[datetime.datetime]:
"""The timestamp of the loaded file."""
return self._items.get("date")

@date.setter
def date(self, value: float) -> None:
self._items["date"] = value
7 changes: 7 additions & 0 deletions tests/test_wv.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ def test_loader_meta_only(reference_waveform_file_name: str, meta):
assert obtained_meta == ref_meta


def test_meta_provides_date_field(reference_waveform_file_name: str, meta):
loader = Load()
parent_storage = loader.load_meta(reference_waveform_file_name)
obtained_meta = parent_storage.storages[0].meta
assert obtained_meta.date == meta["date"]


def test_loader_mwv(
reference_waveform_mwv_file_name: str, meta_mwv: dict, reference_mwv: np.ndarray
):
Expand Down

0 comments on commit 0b685d5

Please sign in to comment.