You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If freq_from_autocorr is given a silent signal d contains a series of 0.
I feel the best solution is to just return some arbitrary value without crashing.
I don't remember if it happens in practice, but a while back I found that parabolic(f, 0) compares to f[-1] (which is wrong but doesn't crash) and parabolic(f, len(f)-1) compares to f[len(x)] which raises IndexError.
The text was updated successfully, but these errors were encountered:
I'm not sure if the frequency estimation function should handle this or not. If it should, it should probably return None, but maybe it should be the calling function's responsibility to only feed it signals with a frequency, or use try .. except to catch the errors when it doesn't.
# if x < 0 or x >= len(f): raise IndexError(add meaningful message?)ifx<=0orx>=len(f) -1:
return (x, f[x]) # generates IndexError for x >= len(f), but not x < 0
Also, since freq_from_autocorr performs DC removal, I feel it's unacceptable (for my use cases) for a utility function to crash given any DC input, due to an unhandled internal IndexError. I think to make the function easier to integrate into surrounding code, it should provide a result (f=0?) with the same type as normal execution, or maybe raising ValueError (though I still don't like the idea of a frequency estimator crashing and taking down the entire app, given hard-to-estimate input where I probably don't care about the frequency).
If
freq_from_autocorr
is given a silent signald
contains a series of 0.I feel the best solution is to just return some arbitrary value without crashing.
I don't remember if it happens in practice, but a while back I found that
parabolic(f, 0)
compares to f[-1] (which is wrong but doesn't crash) andparabolic(f, len(f)-1)
compares to f[len(x)] which raises IndexError.The text was updated successfully, but these errors were encountered: