endolith / endolith/waveform-analysis

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

Open
#38 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
287
Forks
83
Avg merge
16m
Merged PRs (30d)
2

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.