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

Possibility for "IndexError" if frequency is low and frequency estimation goes on the wrong side #38

Open
khaut opened this issue Dec 3, 2024 · 0 comments

Comments

@khaut
Copy link

khaut commented Dec 3, 2024

When doing testing I noticed that there is possibility for "IndexError" if frequency is low and frequency estimation (that can slightly vary on frequency) gives abit too high number. Line number below might be off because of my debugging things.


waveform_analysis/thd.py", line 235, in THD
    ampl = abs(f[i * h])
               ~^^^^^^^
IndexError: index 6006 is out of bounds for axis 0 with size 6001

I've tried to use "if ..." to check that there actually is that index and that helped, but maybe there is better, more optimized way to do it. At least it gets the error go away.


if i * h <= len(f):
    ampl = abs(f[i * h])
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

1 participant