chipmuenk / pyfda

Python Filter Design Analysis Tool
http://chipmuenk.github.io/
MIT License
643 stars 94 forks source link

Convertion to INT Crashes pyfdax #230

Closed Tarik-T closed 11 months ago

Tarik-T commented 1 year ago

pyFDA is a remarkably beautiful and powerful tool. Thank you for making it available to the public!

Although it worked well for many design steps and filter evaluation, at the moment it crashes when I ask for integer coefficients, as follows:

Traceback (most recent call last): File "C:\Python310\lib\site-packages\pyfda\input_widgets\input_coeffs.py", line 840, in fx_base2qdict self.qdict2ui() File "C:\Python310\lib\site-packages\pyfda\input_widgets\input_coeffs.py", line 795, in qdict2ui self.refresh_table() File "C:\Python310\lib\site-packages\pyfda\input_widgets\input_coeffs.py", line 630, in refresh_table self._refresh_table_item(row, col) File "C:\Python310\lib\site-packages\pyfda\input_widgets\input_coeffs.py", line 552, in _refresh_table_item if self.ba_q[col + 2][row] > 0: TypeError: 'int' object is not subscriptable

Steps: load filter from config file update all fields (Like Fbp, Fsb, Fc, etc. by clicking into it, as the fields are not updated by loading the filter data (A minor bug in my mind) Set Filter design class , as this is not part of saved / loaded data Design Filter p3

Switching to tab "b, a" p2

Selecting in the box from "float" to "DEC" -> Crash

I can't rule out the possibility that I'm doing something wrong, but it would be nice if a misoperation ended with an error message rather than a crash.

chipmuenk commented 1 year ago

Thanks for the warm words! If the software crashes, there is obviously something wrong with the software itself :-)

I have two ideas about the cause of the crash (although I cannot reproduce it):

Could you please check your pyfda version, attach your filter file (also for debugging the filter import routines) and retry designing your filter with integer coefficients without importing a filter file? Thanks a lot for your help!

Tarik-T commented 1 year ago

I'm sorry - version is 0.7.1 Remaining version information (just to be on the safe side), below. I agree that a sampling frequency of 1 Hz and a filter frequency of 300 doesn't match very well. I think I forgot to update sample freq (It is 19200) after importing the filter design file: Butter375.npz.zip (Suffix is seems to be zip, but remove that. It is npz).

I believe there is a special function hidden on the "b,a" tab that is randomly (I have not found the trigger yet, but keep trying :-) .) activated when someone wants integer coefficients. I have another one at that stage. I hope it makes it easier for you in figuring out the issue.

Traceback (most recent call last): File "C:\Python310\lib\site-packages\pyfda\input_widgets\input_coeffs.py", line 325, in process_sig_rx self.load_dict() File "C:\Python310\lib\site-packages\pyfda\input_widgets\input_coeffs.py", line 661, in load_dict self.qdict2ui() # set quantization UI from dictionary File "C:\Python310\lib\site-packages\pyfda\input_widgets\input_coeffs.py", line 795, in qdict2ui self.refresh_table() File "C:\Python310\lib\site-packages\pyfda\input_widgets\input_coeffs.py", line 630, in refresh_table self._refresh_table_item(row, col) File "C:\Python310\lib\site-packages\pyfda\input_widgets\input_coeffs.py", line 552, in _refresh_table_item if self.ba_q[col + 2][row] > 0: TypeError: 'int' object is not subscriptable

Nevertheless, thanks to this nice tool, I am making progress in understanding and developing and digital filters.

Thanks! Tarik


C:\Python310\lib\site-packages\pyfda

User Module Dir None Home Dir C:\Users\Tarik Temp Dir C:\Users\Tarik\AppData\Local\Temp Config Dir C:\Users\Tarik.pyfda


pyFDA Config C:\Users\Tarik.pyfda\pyfda.conf Log. Config C:\Users\Tarik.pyfda\pyfda_log.conf Logfile C:\Users\Tarik\AppData\Local\Temp.pyfda\pyfda.log

External modules and libraries Module Version Licence Purpose Python 3.10.2 (64 Bit) PSF numpy 1.23.3 BSD Fast array numerics scipy 1.9.3 (no mkl) BSD Library for scientific computing numexpr 2.8.3 MIT Fast numerical array expression matplotlib 3.6.1 PSF-based Plotting library Qt5 5.15.2 LPGLv3 Widget library (UI etc.) PyQt 5.15.7 GPLv3 Python bindings for Qt5 Markdown 3.4.1 BSD Markdown implementation docutils 0.19 GPLv3 a.o. Plain text -> markup formats mplcursors 0.5.2 MIT Interactive cursors (needs Matplotlib >= 3.1) YOSYS not found ISC Framework for Verilog RTL synthesis

chipmuenk commented 1 year ago

Thanks, I can reproduce the crash!

chipmuenk commented 1 year ago

I had to rewrite the part for reading and writing filters as numpy arrays with irregular shapes ("ragged arrays") are discouraged / deprecated (https://numpy.org/devdocs/release/1.24.0-notes.html) and have become difficult to handle. Therefore, pyfda v0.8.0 no longer crashes but it also cannot read the old filter format anymore. Sorry aboout that!

inxksp commented 12 months ago

Good day! I have the same problem. Version: 0.8.2 (Windows). When I click on the save icon the program closes. Terminal message: ValueError: "setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part." If you save Float then there is no problem. The problem is only when saving Fixpoint. hilbert_pyfdax.zip

chipmuenk commented 12 months ago

Thanks for reporting, probably you're right and the bug is in the same region of code. I'll take a look!

chipmuenk commented 11 months ago

Fixed in latest, please test! Version 0.8.3 will be released today or tomorrow.