From 126cffa33cd75fcc64fe03b18b6d88b0807e1f76 Mon Sep 17 00:00:00 2001 From: Jason Neal Date: Thu, 29 Sep 2016 09:30:06 +0100 Subject: [PATCH] Test interpolation works when just given an numpy array Instead of a Spectrum --- spectrum_overload/test/test_Spectrum.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spectrum_overload/test/test_Spectrum.py b/spectrum_overload/test/test_Spectrum.py index 92b615d..4857764 100644 --- a/spectrum_overload/test/test_Spectrum.py +++ b/spectrum_overload/test/test_Spectrum.py @@ -291,4 +291,20 @@ def test_interpolation(): # Need to write better tests! +def test_interpolation_when_given_a_ndarray(): + + x1 = [1., 2., 3., 4., 5.] + y1 = [2., 4., 6., 8., 10] + x2 = [1.5, 2, 3.5, 4] + # y2 = [1., 2., 1., 2.] + S1 = Spectrum(y1, x1) + # S2 = Spectrum(y2, x2) + S_lin = copy.copy(S1) + S_lin.interpolate_to(np.asarray(x2), kind='linear') + + assert np.allclose(S_lin.flux, [3., 4., 7., 8.]) + # test linear interpoation matches numpy interp + assert np.allclose(S_lin.flux, np.interp(x2, x1, y1)) + + # test_doppler_shift_with_hypothesis()