diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-06-29 20:31:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-29 20:31:19 -0700 |
commit | a9da006c98e36b58a94180f3f9e56ce75ee3b989 (patch) | |
tree | 942aef845d1b55c0deba6a34551a041b72a4fdae /numpy/lib/tests/test_function_base.py | |
parent | f85bf1776b86d306132e310e8152448d4ca452cc (diff) | |
parent | fad8c8f9f572db79391e6819f3880026cf9bb3f5 (diff) | |
download | numpy-a9da006c98e36b58a94180f3f9e56ce75ee3b989.tar.gz |
Merge pull request #11440 from jackvreeken/fix-interp-for-nan-inf
BUG: fix interpolation with inf and NaN present
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 4103a9eb3..d2a9181db 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -2237,6 +2237,14 @@ class TestInterp(object): x0 = np.nan assert_almost_equal(np.interp(x0, x, y), x0) + def test_non_finite_behavior(self): + x = [1, 2, 2.5, 3, 4] + xp = [1, 2, 3, 4] + fp = [1, 2, np.inf, 4] + assert_almost_equal(np.interp(x, xp, fp), [1, 2, np.inf, np.inf, 4]) + fp = [1, 2, np.nan, 4] + assert_almost_equal(np.interp(x, xp, fp), [1, 2, np.nan, np.nan, 4]) + def test_complex_interp(self): # test complex interpolation x = np.linspace(0, 1, 5) @@ -2251,6 +2259,12 @@ class TestInterp(object): x0 = 2.0 right = 2 + 3.0j assert_almost_equal(np.interp(x0, x, y, right=right), right) + # test complex non finite + x = [1, 2, 2.5, 3, 4] + xp = [1, 2, 3, 4] + fp = [1, 2+1j, np.inf, 4] + y = [1, 2+1j, np.inf+0.5j, np.inf, 4] + assert_almost_equal(np.interp(x, xp, fp), y) # test complex periodic x = [-180, -170, -185, 185, -10, -5, 0, 365] xp = [190, -190, 350, -350] |