diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2010-05-24 15:47:32 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2010-05-24 15:47:32 +0000 |
commit | f859af0b27132c3d8dc242a7bcbd9d1ae62b1c72 (patch) | |
tree | 81209caaf46035059a78a162367c5f718e715311 /numpy/lib/tests/test_function_base.py | |
parent | 700512a60586b01e4bc5e33e74d0e1c87a5b6a8f (diff) | |
download | numpy-f859af0b27132c3d8dc242a7bcbd9d1ae62b1c72.tar.gz |
ENH: Test the exceptions and the left, right keywords of the interp
function.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 73fcc5621..e345f5668 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -935,12 +935,22 @@ class TestBincount(TestCase): class TestInterp(TestCase): + def test_exceptions(self): + assert_raises(ValueError, interp, 0, [], []) + assert_raises(ValueError, interp, 0, [0], [1, 2]) + def test_basic(self): x = np.linspace(0, 1, 5) y = np.linspace(0, 1, 5) x0 = np.linspace(0, 1, 50) assert_almost_equal(np.interp(x0, x, y), x0) + def test_right_left_behavior(self): + assert_equal(interp([-1, 0, 1], [0], [1]), [1,1,1]) + assert_equal(interp([-1, 0, 1], [0], [1], left=0), [0,1,1]) + assert_equal(interp([-1, 0, 1], [0], [1], right=0), [1,1,0]) + assert_equal(interp([-1, 0, 1], [0], [1], left=0, right=0), [0,1,0]) + def test_scalar_interpolation_point(self): x = np.linspace(0, 1, 5) y = np.linspace(0, 1, 5) |