diff options
author | ahaldane <ealloc@gmail.com> | 2016-05-12 22:06:24 -0400 |
---|---|---|
committer | ahaldane <ealloc@gmail.com> | 2016-05-12 22:06:24 -0400 |
commit | f1a36312b0996495a499ec4e5a9de14148bf957c (patch) | |
tree | 0b79ef2ae35d85b6fe08ef52b23ac08a5e1b9f02 /numpy/lib/tests/test_function_base.py | |
parent | 383d800042769fc5aa159ff33988a3972e6d577f (diff) | |
parent | 6aa21ad951e8334ba3d3ac677390f7afe76cd242 (diff) | |
download | numpy-f1a36312b0996495a499ec4e5a9de14148bf957c.tar.gz |
Merge pull request #6872 from pec27/complex-interp
ENH: linear interpolation of complex values in lib.interp
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 044279294..0f71393ad 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -2235,6 +2235,28 @@ class TestInterp(TestCase): assert_almost_equal(np.interp(x0, x, y), x0) x0 = np.nan assert_almost_equal(np.interp(x0, x, y), x0) + + def test_complex_interp(self): + # test complex interpolation + x = np.linspace(0, 1, 5) + y = np.linspace(0, 1, 5) + (1 + np.linspace(0, 1, 5))*1.0j + x0 = 0.3 + y0 = x0 + (1+x0)*1.0j + assert_almost_equal(np.interp(x0, x, y), y0) + # test complex left and right + x0 = -1 + left = 2 + 3.0j + assert_almost_equal(np.interp(x0, x, y, left=left), left) + x0 = 2.0 + right = 2 + 3.0j + assert_almost_equal(np.interp(x0, x, y, right=right), right) + # test complex periodic + x = [-180, -170, -185, 185, -10, -5, 0, 365] + xp = [190, -190, 350, -350] + fp = [5+1.0j, 10+2j, 3+3j, 4+4j] + y = [7.5+1.5j, 5.+1.0j, 8.75+1.75j, 6.25+1.25j, 3.+3j, 3.25+3.25j, + 3.5+3.5j, 3.75+3.75j] + assert_almost_equal(np.interp(x, xp, fp, period=360), y) def test_zero_dimensional_interpolation_point(self): x = np.linspace(0, 1, 5) |