def test_interp2(): """Test our two-point interpolator.""" interp = _Interp2('zero') x = np.ones((1, 100)) interp['y'] = np.array([[10.]]) interp['y'] = np.array([[-10]]) interp.n_samp = 100 out = np.zeros_like(x) interp.interpolate('y', x, out) expected = 10 * x assert_allclose(out, expected, atol=1e-7) # Linear interp.interp = 'linear' out.fill(0.) interp.interpolate('y', x, out) expected = np.linspace(10, -10, 100, endpoint=False)[np.newaxis] assert_allclose(out, expected, atol=1e-7)