def test_linear(self): N = 3000. x = arange(N) y = arange(N) new_x = arange(N)+0.5 new_y = linear(x, y, new_x) self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5])
def test_linear(self): N = 3000. x = arange(N) y = arange(N) new_x = arange(N)+0.5 with suppress_warnings() as sup: sup.filter(DeprecationWarning, "`linear` is deprecated") new_y = linear(x, y, new_x) assert_allclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5])
def test_linear_interp(): n = 10 x = np.arange(n, dtype=np.float) y = np.arange(n, dtype=np.float) new_x = np.arange(n, dtype=np.float) + 0.5 scipy_new_y = linear(x, y, new_x) np.testing.assert_almost_equal(scipy_new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5]) for i in range(n - 1): assert vic_lib.linear_interp(new_x[i], x[i], x[i + 1], y[i], y[i + 1]) == scipy_new_y[i]
def test_linear(self): N = 3000. x = arange(N) y = arange(N) new_x = arange(N)+0.5 with warnings.catch_warnings(): warnings.simplefilter("ignore", DeprecationWarning) new_y = linear(x, y, new_x) self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5])
def test_linear(self): N = 3000. x = arange(N) y = arange(N) new_x = arange(N)+0.5 t1 = time.clock() new_y = linear(x, y, new_x) t2 = time.clock() #print "time for linear interpolation with N = %i:" % N, t2 - t1 self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5])
def test_linear2(self): N = 3000 x = arange(N, dtype=np.float) y = ones((100,N)) * arange(N) new_x = arange(N) + 0.5 new_y = linear(x, y, new_x) self.assertAllclose(new_y[:5,:5], [[0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5]])
def test_linear2(self): N = 3000 x = arange(N, dtype=float) y = ones((100,N)) * arange(N) new_x = arange(N) + 0.5 with suppress_warnings() as sup: sup.filter(DeprecationWarning, "`linear` is deprecated") new_y = linear(x, y, new_x) assert_allclose(new_y[:5,:5], [[0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5]])
def test_linear2(self): N = 3000 x = arange(N, dtype=float) y = ones((100,N)) * arange(N) new_x = arange(N) + 0.5 with warnings.catch_warnings(): warnings.simplefilter("ignore", DeprecationWarning) new_y = linear(x, y, new_x) self.assertAllclose(new_y[:5,:5], [[0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5]])
def test_linear2(self): N = 3000. x = arange(N) y = ones((100, N)) * arange(N) new_x = arange(N) + 0.5 t1 = time.clock() new_y = linear(x, y, new_x) t2 = time.clock() #print "time for 2D linear interpolation with N = %i:" % N, t2 - t1 self.assertAllclose( new_y[:5, :5], [[0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5], [0.5, 1.5, 2.5, 3.5, 4.5]])