Exemple #1
0
 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('1d interp (sec):', t2 - t1)
     self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5])
Exemple #2
0
 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('fast interpolate (sec):', 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]])
Exemple #3
0
 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('fast interpolate (sec):', 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]])