Skip to content

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

Open
@khaut

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions