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

interp1d with periodic data not working as expected #33

Closed
dpanici opened this issue Jun 11, 2024 · 1 comment
Closed

interp1d with periodic data not working as expected #33

dpanici opened this issue Jun 11, 2024 · 1 comment

Comments

@dpanici
Copy link

dpanici commented Jun 11, 2024

When using interp1d with period given, the expected result is an interpolation assuming the signal is periodic. However in 0.3.2 it seems that this is not what is returned.

MWE:

from interpax import interp1d
import jax.numpy as jnp

xq = jnp.linspace(0,2*jnp.pi,endpoint=True)
x = jnp.linspace(0,2*jnp.pi,4,endpoint=False)
f = jnp.array([12,10,8,10])

fq= interp1d(xq, x, f, period=2*jnp.pi,method="cubic",derivative=0)

print(fq)

import matplotlib.pyplot as plt
plt.figure()
plt.plot(xq,fq)
plt.scatter(x,f)

import interpax
plt.title(f"interpax version {interpax.__version__}")

image

image

The change in 0.3.2 seems to be that the _make_periodic function no longer pads the x points to enforce periodicity (i.e. does not make the x and f arrays first and last points be the same). The above snippet works fine in 0.3.2 with linear as the interpolation method, but not with cubic or cubic2 (I have not tried the others)

@f0uriest
Copy link
Owner

This should be resolved by #34. I've pulled v0.3.2 and released a new v0.3.3 that undoes this change.

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

2 participants