Skip to content

Commit

Permalink
Test interpolation works when just given an numpy array
Browse files Browse the repository at this point in the history
Instead of a Spectrum
  • Loading branch information
jason-neal committed Sep 29, 2016
1 parent 0e638d4 commit 126cffa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spectrum_overload/test/test_Spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 126cffa

Please sign in to comment.