Closed muschellij2 closed 2 years ago
Thanks for reporting this, and sorry it's taken me so long to come around to responding.
This is definitely more than a floating point precision issue. What you're seeing here is a boundary effect arising from a sharp discontinuity at the end of the signal, x[-1] = 49.9, transitioning implicitly to zero outside of the signal's domain. This discontinuity induces ringing in the filter response, which shows up as ripples near the end of the signal.
This is more or less expected behavior in general, but for the specific case where the input and output sampling rates are identical, I agree that it should be avoided by not doing any interpolation whatsoever. In fact, the librosa resampling interface (which can use resampy, among other backends) does perform this check:
which is probably why I didn't implement it here as well.
As an aside, the way you're checking for equivalence isn't stable:
r = y_same == x r.all()
Instead, you should use np.allclose(y_same, x)
which checks for equivalence down to floating point precision. For the specific case here, it shouldn't matter, but something to be aware of in general.
Resampling with the same
hz
should likely give the exact result back. It doesn't (likely up to some floating point value).Created on 2020-11-29 by the reprexpy package