Skip to content
Snippets Groups Projects

Guifilesignal

Merged Olle Hansson requested to merge guifilesignal into master
2 unresolved threads
Files
5
+ 6
16
@@ -165,7 +165,7 @@ class ZeroPad(SignalGenerator):
class FromFile(SignalGenerator):
"""
Signal generator that reads from file and pads a sequence with zeros.
File should be of type .txt or .csv and contain a single column vector
Parameters
----------
path : string
@@ -173,20 +173,10 @@ class FromFile(SignalGenerator):
"""
def __init__(self, path) -> None:
try:
Path(path).resolve(strict=True)
except FileNotFoundError:
raise Exception("Selected input file not found.")
try:
data = np.loadtxt(path, dtype=complex).tolist()
self._data = data
self._len = len(data)
except ValueError:
raise Exception(
"Selected input file is not of the right format, should be of filetype"
" .txt or .csv and contain single column input vector."
)
self._path = path
data = np.loadtxt(path, dtype=complex).tolist()
self._data = data
self._len = len(data)
def __call__(self, time: int) -> complex:
if 0 <= time < self._len:
@@ -194,7 +184,7 @@ class FromFile(SignalGenerator):
return 0.0
def __repr__(self) -> str:
return f"FromFile({self._data})"
return f"FromFile({self._path!r})"
class Sinusoid(SignalGenerator):
Loading