BUG: CubicSpline segfaults when passing empty values for `y`with numpy >=1.23
See original GitHub issueDescribe your issue.
While the docs are clear and the values for y
must be finite, one could pass empty array and, some iterative interpolations we had in our code that relied on that behavior, “worked.”
We fixed our code to return a ValueError now instead of relying on that behaviour. However, b/c the old code segfaults, maybe some checks should be in place in SciPy to avoid empty y
values. Please feel free to close this issue if this doesn’t make sense.
Reproducing Code Example
from scipy.interpolate import CubicSpline
import numpy as np
# Segfaults on my machine when it reaches size>=10 but passes with <10.
x = np.arange(10)
y = np.empty(len(x)) * np.NaN
y_no_nans = y[~np.isnan(y)].reshape(y.shape[0], -1)
# In our code y_no_nans was slowly iterated to reach valid finite value and worked for numpy <1.23.
spline = CubicSpline(x, y_no_nans, bc_type='periodic')
Error message
Sometimes it segfaults, sometimes it "works" :-/
SciPy/NumPy/Python version information
1.9.1 1.23.3 sys.version_info(major=3, minor=10, micro=6, releaselevel=‘final’, serial=0)
Issue Analytics
- State:
- Created a year ago
- Comments:11 (9 by maintainers)
Top Results From Across the Web
ocefpaf (Filipe) · GitHub
BUG : CubicSpline segfaults when passing empty values for y with numpy >=1.23. Describe your issue. While the docs are clear and the...
Read more >How to extend NumPy
A good description of how to use the first function is contained in the Python C-API reference manual under section 5.5 (Parsing arguments...
Read more >Gnuplot-4 4 0 | PDF | Computer File - Scribd
array of values constitutes column 3. ... binary or ASCII, general binary does not treat the generated columns as 1, 2 or 3...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ocefpaf heads up: https://github.com/scipy/scipy/pull/17305 is in, thank you for working on this!
OK, https://github.com/scipy/scipy/pull/17305 implements the suggested API with an intent to close this issue. Reviews would be appreciated.