summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 6381c0a72..10e3790ea 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -69,7 +69,7 @@ class TestAverage(TestCase):
actual = average(y, weights=w)
desired = (arange(10) ** 2).sum()*1. / arange(10).sum()
assert_almost_equal(actual, desired)
-
+
y1 = array([[1, 2, 3], [4, 5, 6]])
w0 = [1, 2]
actual = average(y1, weights=w0, axis=0)
@@ -934,6 +934,34 @@ class TestBincount(TestCase):
assert_array_equal(y, np.array([0, 0.2, 0.5, 0, 0.5, 0.1]))
+class TestInterp(TestCase):
+ 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_scalar_interpolation_point(self):
+ x = np.linspace(0, 1, 5)
+ y = np.linspace(0, 1, 5)
+ x0 = 0
+ assert_almost_equal(np.interp(x0, x, y), x0)
+ x0 = .3
+ assert_almost_equal(np.interp(x0, x, y), x0)
+ x0 = np.float32(.3)
+ assert_almost_equal(np.interp(x0, x, y), x0)
+ x0 = np.float64(.3)
+ assert_almost_equal(np.interp(x0, x, y), x0)
+
+ def test_zero_dimensional_interpolation_point(self):
+ x = np.linspace(0, 1, 5)
+ y = np.linspace(0, 1, 5)
+ x0 = np.array(.3)
+ assert_almost_equal(np.interp(x0, x, y), x0)
+ x0 = np.array(.3, dtype=object)
+ assert_almost_equal(np.interp(x0, x, y), .3)
+
+
def compare_results(res, desired):
for i in range(len(desired)):
assert_array_equal(res[i], desired[i])