question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: CubicSpline segfaults when passing empty values for `y`with numpy >=1.23

See original GitHub issue

Describe 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:closed
  • Created a year ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
ev-brcommented, Nov 27, 2022

@ocefpaf heads up: https://github.com/scipy/scipy/pull/17305 is in, thank you for working on this!

1reaction
ev-brcommented, Oct 29, 2022

OK, https://github.com/scipy/scipy/pull/17305 implements the suggested API with an intent to close this issue. Reviews would be appreciated.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found