make_interp_spline does not return a periodic spline for k=0 and k=1 when bc_type="periodic"
Author: faymannsCreated Sep 14, 2026Updated Sep 15, 2026
Labelscat:bugcontribution welcomeprio:medium
Description
When you create an interpolating spline using cupyx.scipy.interpolate.make_interp_spline(x, y, k=k, bc_type="periodic"), the returned spline is not periodic for k=0 and k=1.
The same issue exists in scipy and we are working on a PR to fix it.
To Reproduce
import cupy as cp
import cupyx.scipy.interpolate as interpolate
import matplotlib.pyplot as plt
x = cp.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
y = cp.array([1.0, 1.5, 2.5, 2.0, 0.5, 1.0])
x_plot = cp.linspace(-5, 10, 1000)
fig, axes = plt.subplots(5, 1)
for k in range(5):
spl = interpolate.make_interp_spline(
x,
y,
k=k,
bc_type="periodic",
)
axes[k].scatter(
cp.asnumpy(x),
cp.asnumpy(y),
)
axes[k].plot(
cp.asnumpy(x_plot),
cp.asnumpy(spl(x_plot)),
)
print(f"{k = } \t {spl.extrapolate = }")
spl.extrapolate = "periodic"
axes[k].plot(
cp.asnumpy(x_plot),
cp.asnumpy(spl(x_plot)),
)
plt.savefig("cupy_make_interp_spline.png")This generates the following output:
k = 0 spl.extrapolate = True
k = 1 spl.extrapolate = True
k = 2 spl.extrapolate = 'periodic'
k = 3 spl.extrapolate = 'periodic'
k = 4 spl.extrapolate = 'periodic'Installation
Wheel (pip install cupy-***)
Environment
python -c "import cupy; cupy.show_config(_full=True)" doesn't seem to work correctly. See the output below:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/data/aymanns/venv_cupy/lib/python3.10/site-packages/cupy/__init__.py", line 945, in show_config
_sys.stdout.write(str(cupyx.get_runtime_info(full=_full)))
File "/data/aymanns/venv_cupy/lib/python3.10/site-packages/cupyx/_runtime.py", line 421, in get_runtime_info
return _RuntimeInfo(full=full)
File "/data/aymanns/venv_cupy/lib/python3.10/site-packages/cupyx/_runtime.py", line 305, in __init__
self.scipy_version = scipy.version.full_version
AttributeError: module 'scipy' has no attribute 'version'Additional Information
No response
Source: cupy/cupy