(编辑以避免在线问题上的点) 运行以下代码:
from scipy.interpolate import LinearNDInterpolator
import numpy as np
points = np.array([[ 0, 0],
[1, 0],
[ 0, 1]])
values = np.array([-3, 8, -2])
ip = LinearNDInterpolator(points, values)
在我的计算机上产生输出
Segmentation fault: 11
为了尝试修复它,我最近卸载并重新安装了 numpy 和 scipy,这样
scipy.版本 ‘1.3.3’ numpy.版本 '1.17.4'
但运气不好
最佳答案
这不一定是答案,而只是更多信息,当我执行确切的代码时,我将其作为输出全部作为错误颜色:
Traceback (most recent call last):
File "/Users/tadhgmcdonald-jensen/Documents/test.py", line 8, in <module>
interp = LinearNDInterpolator(pts, z, fill_value= np.nan)
File "interpnd.pyx", line 248, in scipy.interpolate.interpnd.LinearNDInterpolator.__init__
File "qhull.pyx", line 1833, in scipy.spatial.qhull.Delaunay.__init__
File "qhull.pyx", line 355, in scipy.spatial.qhull._Qhull.__init__
scipy.spatial.qhull.QhullError: QH6154 Qhull precision error: Initial simplex is flat (facet 1 is coplanar with the interior point)
While executing: | qhull d Q12 Qbb Qc Qt Qz
Options selected for Qhull 2015.2.r 2016/01/18:
run-id 923456758 delaunay Q12-no-wide-dup Qbbound-last Qcoplanar-keep
Qtriangulate Qz-infinity-point _pre-merge _zero-centrum Qinterior-keep
Pgood _max-width 2 Error-roundoff 5.5e-15 _one-merge 3.9e-14
Visible-distance 1.1e-14 U-coplanar-distance 1.1e-14 Width-outside 2.2e-14
_wide-facet 6.7e-14
precision problems (corrected unless 'Q0' or an error)
2 flipped facets
The input to qhull appears to be less than 3 dimensional, or a
computation has overflowed.
Qhull could not construct a clearly convex simplex from points:
- p1(v3): 2 3 0.71
- p3(v2): 2 3 2
- p2(v1): 3 4 1.8
- p0(v0): 1 2 5.6e-17
The center point is coplanar with a facet, or a vertex is coplanar
with a neighboring facet. The maximum round off error for
computing distances is 5.5e-15. The center point, facets and distances
to the center point are as follows:
center point 2 3 1.122
facet p3 p2 p0 distance= 0
facet p1 p2 p0 distance= 0
facet p1 p3 p0 distance= 0
facet p1 p3 p2 distance= 0
These points either have a maximum or minimum x-coordinate, or
they maximize the determinant for k coordinates. Trial points
are first selected from points that maximize a coordinate.
The min and max coordinates for each dimension are:
0: 1 3 difference= 2
1: 2 4 difference= 2
2: 5.551e-17 2 difference= 2
If the input should be full dimensional, you have several options that
may determine an initial simplex:
- use 'QJ' to joggle the input and make it full dimensional
- use 'QbB' to scale the points to the unit cube
- use 'QR0' to randomly rotate the input for different maximum points
- use 'Qs' to search all points for the initial simplex
- use 'En' to specify a maximum roundoff error less than 5.5e-15.
- trace execution with 'T3' to see the determinant for each point.
If the input is lower dimensional:
- use 'QJ' to joggle the input and make it full dimensional
- use 'Qbk:0Bk:0' to delete coordinate k from the input. You should
pick the coordinate with the least range. The hull will have the
correct topology.
- determine the flat containing the points, rotate the points
into a coordinate plane, and delete the other coordinates.
- add one or more points to make the input full dimensional.
我对 scipy 的了解不够,无法确切地知道发生了什么,但是您的输入是否可能无效,而您碰巧在机器上没有得到有意义的输出?这可能与向 scipy 报告错误有关。
scipy.version.version == '1.3.1' 和 numpy.version.version == '1.17.3'
关于python - 运行 scipy interpolate 时出现段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59274750/