chipmuenk/pyfda

exporting filter coefficients as numpy/zipped numpy fails silently

Closed this issue · 2 comments

dsvf commented

I designed a FIR filter and wanted to export it to .npy or .npz. Export to CSV works as expected.
When saving, no file is created and no error appears in the bottom console.

Python 3.8.10
Numpy 1.24.3
latest pyFDA version
Python prints the following error(s):

  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/input_widgets/input_specs.py", line 202, in <lambda>
    self.butSaveFilt.clicked.connect(lambda: save_filter(self))
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 1400, in save_filter
    np.savez(f, **fb.fil[0])
  File "<__array_function__ internals>", line 200, in savez
  File "/home/phil/.local/lib/python3.8/site-packages/numpy/lib/npyio.py", line 615, in savez
    _savez(file, args, kwds, False)
  File "/home/phil/.local/lib/python3.8/site-packages/numpy/lib/npyio.py", line 716, in _savez
    val = np.asanyarray(val)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3,) + inhomogeneous part.
Exception ignored in: <function ZipFile.__del__ at 0x7f1c46251820>
Traceback (most recent call last):
  File "/usr/lib/python3.8/zipfile.py", line 1821, in __del__
    self.close()
  File "/usr/lib/python3.8/zipfile.py", line 1838, in close
    self.fp.seek(self.start_dir)
ValueError: seek of closed file
Traceback (most recent call last):
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/input_widgets/input_coeffs.py", line 683, in _export
    qtable2text(self.tblCoeff, self.ba, self, 'ba', self.QObj[0].q_dict['fx_base'],
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 283, in qtable2text
    export_csv_data(parent, text, fkey, title=title)
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 971, in export_csv_data
    np_data = csv2array(io.StringIO(data))  # convert csv data to numpy array
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 399, in csv2array
    np.warnings.filterwarnings('error', category=np.VisibleDeprecationWarning)
  File "/home/phil/.local/lib/python3.8/site-packages/numpy/__init__.py", line 320, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'warnings'
Traceback (most recent call last):
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/input_widgets/input_coeffs.py", line 683, in _export
    qtable2text(self.tblCoeff, self.ba, self, 'ba', self.QObj[0].q_dict['fx_base'],
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 283, in qtable2text
    export_csv_data(parent, text, fkey, title=title)
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 971, in export_csv_data
    np_data = csv2array(io.StringIO(data))  # convert csv data to numpy array
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 399, in csv2array
    np.warnings.filterwarnings('error', category=np.VisibleDeprecationWarning)
  File "/home/phil/.local/lib/python3.8/site-packages/numpy/__init__.py", line 320, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'warnings'
Traceback (most recent call last):
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/input_widgets/input_coeffs.py", line 683, in _export
    qtable2text(self.tblCoeff, self.ba, self, 'ba', self.QObj[0].q_dict['fx_base'],
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 283, in qtable2text
    export_csv_data(parent, text, fkey, title=title)
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 971, in export_csv_data
    np_data = csv2array(io.StringIO(data))  # convert csv data to numpy array
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 399, in csv2array
    np.warnings.filterwarnings('error', category=np.VisibleDeprecationWarning)
  File "/home/phil/.local/lib/python3.8/site-packages/numpy/__init__.py", line 320, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'warnings'
[   INFO] [pyfda.libs.pyfda_io_lib:1031] Filter saved as
	"/home/phil/tmp/bla.csv"
Traceback (most recent call last):
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/input_widgets/input_coeffs.py", line 683, in _export
    qtable2text(self.tblCoeff, self.ba, self, 'ba', self.QObj[0].q_dict['fx_base'],
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 283, in qtable2text
    export_csv_data(parent, text, fkey, title=title)
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 971, in export_csv_data
    np_data = csv2array(io.StringIO(data))  # convert csv data to numpy array
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 399, in csv2array
    np.warnings.filterwarnings('error', category=np.VisibleDeprecationWarning)
  File "/home/phil/.local/lib/python3.8/site-packages/numpy/__init__.py", line 320, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'warnings'
Traceback (most recent call last):
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/input_widgets/input_coeffs.py", line 683, in _export
    qtable2text(self.tblCoeff, self.ba, self, 'ba', self.QObj[0].q_dict['fx_base'],
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 283, in qtable2text
    export_csv_data(parent, text, fkey, title=title)
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 971, in export_csv_data
    np_data = csv2array(io.StringIO(data))  # convert csv data to numpy array
  File "/home/phil/.local/lib/python3.8/site-packages/pyfda/libs/pyfda_io_lib.py", line 399, in csv2array
    np.warnings.filterwarnings('error', category=np.VisibleDeprecationWarning)
  File "/home/phil/.local/lib/python3.8/site-packages/numpy/__init__.py", line 320, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'warnings'

I have the same issue.
I think it's the numpy version to blame.

No, I'm to blame :-) ... This should be fixed in the develop and in the main branch - thanks for reporting!