def test_rv_cumulative(input_, flag): """Test it works on well formed input.""" result = rv_cumulative(input_, single=flag) assert result[-2] == weighted_error(input_[:-1]) assert result[-1] == weighted_error(input_) if flag: assert result[0] == input_[0]
def test_rv_cumulative_full(input_): result = rv_cumulative_full(input_) assert len(result) == 9 assert result[4] == weighted_error(input_) assert result[0] == input_[0] assert result[-1] == input_[-1] assert isinstance(result, np.ndarray)
def test_increments_rv_accumulate_same_as_full(real_spec, increment_percent, no_mask): """Assuming that the weighted rv from the steps should equal the rv from the band.""" wav, flux, mask = real_spec[0], real_spec[1], real_spec[2] if no_mask: # Try with mask= None also. mask = None rv_full = rv_precision(wav, flux, mask=mask).value x, incremented_rv = incremental_rv(wav, flux, mask=mask, percent=increment_percent) incremented_weighted = weighted_error(incremented_rv) assert np.round(rv_full, 2) == np.round(incremented_weighted, 2) assert x[0] > wav[0] assert [-1] < wav[-1]
def test_weighted_error(input_, expected): result = weighted_error(input_) assert np.allclose(result, expected)