Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convertion to INT Crashes pyfdax #230

Closed
Tarik-T opened this issue Oct 24, 2022 · 7 comments
Closed

Convertion to INT Crashes pyfdax #230

Tarik-T opened this issue Oct 24, 2022 · 7 comments

Comments

@Tarik-T
Copy link

Tarik-T commented Oct 24, 2022

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
Copy link
Owner

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):

  • Are you using v0.7.0? There was a related bug that I fixed in 0.7.1
  • Something seems to be wrong with your filter file - with a sampling frequency of 1 Hz it shouldn't be possible to use a frequency of e.g. f_c = 500 Hz. I agree that the filter import routine is buggy (I'm afraid of touching the related part of the code, it is a big dark mess) and this might also cause the mismatch of sampling and corner frequency.

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
Copy link
Author

Tarik-T commented Oct 24, 2022

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
Copy link
Owner

Thanks, I can reproduce the crash!

@chipmuenk
Copy link
Owner

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
Copy link

inxksp commented Sep 12, 2023

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
Copy link
Owner

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

@chipmuenk
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants