Exemplo n.º 1
0
def test_linear_uy_in_make_equidistant(n):
    # Check for given input, if interpolated uncertainties equal 1 and
    # :math:`sqrt(2) / 2`.
    dt_unit = 2
    t_unit = np.arange(0, n, dt_unit)
    y = uy_unit = np.ones_like(t_unit)
    dt_half = dt_unit / 2
    uy_new = make_equidistant(t_unit, y, uy_unit, dt_half, "linear")[2]
    assert np.all(uy_new[0:n:dt_unit] == 1) and np.all(
        uy_new[1:n:dt_unit] == np.sqrt(2) / 2)
Exemplo n.º 2
0
def test_raise_not_implemented_yet_make_equidistant(interp_inputs):
    # Check that not implemented versions raise exceptions.
    with raises(NotImplementedError):
        make_equidistant(**interp_inputs)
Exemplo n.º 3
0
def test_prev_in_make_equidistant(interp_inputs):
    y_new, uy_new = make_equidistant(**interp_inputs)[1:3]
    # Check if all 'interpolated' values are present in the actual values.
    assert np.all(np.isin(y_new, interp_inputs["y"]))
    assert np.all(np.isin(uy_new, interp_inputs["uy"]))
Exemplo n.º 4
0
def test_linear_in_make_equidistant(interp_inputs):
    y_new, uy_new = make_equidistant(**interp_inputs)[1:3]
    # Check if all interpolated values lie in the range of the original values.
    assert np.all(np.amin(interp_inputs["y"]) <= y_new)
    assert np.all(np.amax(interp_inputs["y"]) >= y_new)
Exemplo n.º 5
0
def test_t_new_to_dt_make_equidistant(interp_inputs):
    t_new = make_equidistant(**interp_inputs)[0]
    delta_t_new = np.diff(t_new)
    # Check if the new timestamps are ascending.
    assert not np.any(delta_t_new < 0)
Exemplo n.º 6
0
def test_wrong_input_lengths_call_make_equidistant(interp_inputs):
    # Check erroneous calls with unequally long inputs.
    with raises(ValueError):
        y_wrong = np.tile(interp_inputs["y"], 2)
        uy_wrong = np.tile(interp_inputs["uy"], 3)
        make_equidistant(interp_inputs["t"], y_wrong, uy_wrong)
Exemplo n.º 7
0
def test_full_call_make_equidistant(interp_inputs):
    t_new, y_new, uy_new = make_equidistant(**interp_inputs)
    # Check the equal dimensions of the minimum calls output.
    assert len(t_new) == len(y_new) == len(uy_new)
Exemplo n.º 8
0
def test_too_short_call_make_equidistant(interp_inputs):
    # Check erroneous calls with too few inputs.
    with raises(TypeError):
        make_equidistant(interp_inputs["t"])
        make_equidistant(interp_inputs["t"], interp_inputs["y"])
Exemplo n.º 9
0
def test_t_new_to_dt_make_equidistant(interp_inputs):
    x_new = make_equidistant(**interp_inputs)[0]
    delta_x_new = np.diff(x_new)
    # Check if x_new is ascending.
    assert not np.any(delta_x_new < 0)