Ejemplo n.º 1
0
 def test_slow_vs_multi(self):
     """Test that slow interp gives same result as
     interpolate_multiple_rows_same_x."""
     result_slow = slow_interp_same_x(self.x, self.xp, self.fp)
     result_multiple = interpolate_multiple_rows_same_x(
         self.x, self.xp, self.fp)
     np.testing.assert_allclose(result_slow, result_multiple)
Ejemplo n.º 2
0
 def test_slow_vs_fast_repeated(self):
     """Test that slow and fast versions give same result when xp
     contains repeats."""
     repeat_xp = self.xp.copy()
     repeat_xp[51] = repeat_xp[50]
     result_slow = slow_interp_same_x(self.x, repeat_xp, self.fp)
     result_fast = fast_interp_same_x(self.x, repeat_xp, self.fp)
     np.testing.assert_allclose(result_slow, result_fast)
Ejemplo n.º 3
0
 def test_slow_vs_fast_unordered(self):
     """Test that slow and fast versions give same result
     when x is not sorted."""
     shuffled_x = self.x.copy()
     np.random.shuffle(shuffled_x)
     result_slow = slow_interp_same_x(shuffled_x, self.xp, self.fp)
     result_fast = fast_interp_same_x(shuffled_x, self.xp, self.fp)
     np.testing.assert_allclose(result_slow, result_fast)
Ejemplo n.º 4
0
 def test_slow(self):
     """Test slow interp against known result."""
     xp = np.array([0, 1, 2, 3, 4], dtype=np.float32)
     fp = np.array([[0, 0.5, 1, 1.5, 2], [0, 2, 4, 6, 8]], dtype=np.float32)
     x = np.array([-1, 0.5, 2], dtype=np.float32)
     expected = np.array([[0, 0.25, 1], [0, 1, 4]], dtype=np.float32)
     result = slow_interp_same_x(x, xp, fp)
     np.testing.assert_allclose(result, expected)
Ejemplo n.º 5
0
 def test_slow_vs_fast(self):
     """Test that slow and fast versions give same result."""
     result_slow = slow_interp_same_x(self.x, self.xp, self.fp)
     result_fast = fast_interp_same_x(self.x, self.xp, self.fp)
     np.testing.assert_allclose(result_slow, result_fast)