Skip to content

Commit

Permalink
Introducing property handling to sig classes
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-hld committed Jun 19, 2024
1 parent 10feec4 commit d317f0f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions spaudiopy/sig.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def __init__(self, signal, fs):
fs : int
"""
self.signal = utils.asarray_1d(signal)
self.fs = fs
self._signal = utils.asarray_1d(signal)
self._fs = fs

def __len__(self):
"""Override len()."""
Expand All @@ -54,6 +54,18 @@ def __getitem__(self, key):
"""Enable [] operator, returns signal data."""
return self.signal[key]

@property
def signal(self):
return self._signal

@signal.setter
def signal(self, value):
self._signal = utils.asarray_1d(value)

@property
def fs(self):
return self._fs

@classmethod
def from_file(cls, filename, fs=None):
"""Alternative constructor, load signal from filename."""
Expand Down Expand Up @@ -122,7 +134,7 @@ def __init__(self, signals, fs=None):
if fs is None:
raise ValueError("Provide fs (as kwarg).")
else:
self.fs = fs
self._fs = fs
for s in signals:
self.channel.append(MonoSignal(s, fs))
self.channel_count = len(self.channel)
Expand Down

0 comments on commit d317f0f

Please sign in to comment.