Skip to content

Commit

Permalink
Merge pull request #20 from Rohde-Schwarz/17-iqw-is-read-with-default…
Browse files Browse the repository at this point in the history
…-meta-data

No default values for IQW files
  • Loading branch information
floschl authored Apr 23, 2024
2 parents e448641 + cf1ed0d commit 2ef8806
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/RsWaveform/iqw/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Load(LoadInterface):

def load(self, file: typing.Union[str, typing.IO, Path]) -> ParentStorage:
"""Load iwq data from file."""
parent_storage = ParentStorage()
parent_storage = ParentStorage(no_defaults=True)
with read_file_handle(file) as fp:
content = fp.read()
iq_data = self._extract_iq(content)
Expand Down
7 changes: 6 additions & 1 deletion src/RsWaveform/meta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@


class Meta(MetaWv, MetaIqtar):
"""Meta data for Storage container."""
"""Meta data for Storage container.
Args:
no_defaults (bool, optional): Storage meta data should have no defaults at
initialization. Defaults to False.
"""

def __init__(self, no_defaults: bool = False, **kwargs):
"""Initialize Meta class."""
Expand Down
18 changes: 15 additions & 3 deletions src/RsWaveform/parent_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@


class ParentStorage(abc.ABC):
"""ParentStorage class implementation."""
"""ParentStorage class implementation.
def __init__(self, number_of_storages: int = 1):
Args:
number_of_storages (int, optional): Initialize number of storages.
Defaults to 1.
no_defaults (bool, optional): Storage meta data should have no defaults at
initialization. Defaults to False.
Raises:
ValueError: If number of storages is smaller than 1.
"""

def __init__(self, number_of_storages: int = 1, no_defaults: bool = False):
"""Initialize ParentStorage class."""
if number_of_storages <= 0:
raise ValueError("Only positive number of storages allowed!")
self._storages = [Storage() for _ in range(number_of_storages)]
self._storages = [
Storage(no_defaults=no_defaults) for _ in range(number_of_storages)
]
self._filename: str = ""
self._timestamp: datetime = datetime.now()

Expand Down
18 changes: 13 additions & 5 deletions src/RsWaveform/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,24 @@ def encode_datetime(obj):


class Storage(abc.ABC):
"""Storage class implementation."""

def __init__(self, serialized: typing.Optional[bytes] = None) -> None:
"""Storage class implementation.
Args:
serialized (typing.Optional[bytes], optional): Serialized data.
Defaults to None.
no_defaults (bool, optional): Storage meta data should have no defaults at
initialization. Defaults to False.
"""

def __init__(
self, serialized: typing.Optional[bytes] = None, no_defaults: bool = False
) -> None:
"""Initialize Storage class."""
if serialized:
self.deserialize(serialized)
else:
self.data: np.ndarray = np.zeros((1024,), dtype=np.complex128)
# self.meta: dict = {}
self.meta: Meta = Meta()
self.meta: Meta = Meta(no_defaults=no_defaults)

@property
def samples(self) -> int:
Expand Down

0 comments on commit 2ef8806

Please sign in to comment.