Notice
Recent Posts
Recent Comments
Link
관리 메뉴

뛰는 놈 위에 나는 공대생

[SciPy] ValueError: One of the requested xi is out of bounds in dimension 0 본문

기타

[SciPy] ValueError: One of the requested xi is out of bounds in dimension 0

보통의공대생 2023. 2. 28. 16:34

scipy에 있는 scipy.interpolate.RegularGridInterpolator를 쓸 때 발생했던 오류이다.

코드를 좀 살펴보면 내가 interpolation하기 위해 넣은 값이 내삽을 위해 지정된 값 범위에서 벗어날 때 return하는 오류이다.

 

예를 들어 나는 x=[0,1,2,3,4]일 때의 y값을 넣어놨는데 만약 x=5.5값을 넣으면 범위 밖에 벗어나므로 처리할 수 없다.

ValueError: One of the requested xi is out of bounds in dimension 0

 

나의 경우에는 내가 x값을 잘못 넣었기 때문에 이런 일이 일어난 거지만 만약 외삽(extrapolate)을 원하는 경우라면

다음과 같이 bounds_error = False로 지정하고 fill_value=None으로 지정해서 외삽도 가능한 것으로 보인다.

Comments