コード例 #1
0
def test_dense_right_interval_vec():
    denseoutput = DenseOutput(None, None)
    inputs = D.array([0, 1, 0, 1, 1, 1])
    interpolator = CubicHermiteInterp(*inputs)
    denseoutput.add_interpolant(1, interpolator)
    denseoutput.add_interpolant(2, interpolator)
    assert (D.all(
        denseoutput.find_interval_vec([0.5, 0.99999, 1.00001, 1.5]) == D.array(
            [0, 0, 1, 1], dtype=D.int64)))
コード例 #2
0
def test_dense_right_interval():
    denseoutput = DenseOutput(None, None)
    inputs = D.array([0, 1, 0, 1, 1, 1])
    interpolator = CubicHermiteInterp(*inputs)
    denseoutput.add_interpolant(1, interpolator)
    denseoutput.add_interpolant(2, interpolator)
    assert (denseoutput.find_interval(0.5) == 0)
    assert (denseoutput.find_interval(0.99999) == 0)
    assert (denseoutput.find_interval(1.00001) == 1)
    assert (denseoutput.find_interval(1.5) == 1)
コード例 #3
0
def test_dense_add_timemismatch_oob():
    inputs = D.array([0, 1, 0, 1, 1, 1])
    interpolator = CubicHermiteInterp(*inputs)
    denseoutput = DenseOutput([0, 1], [interpolator])

    def new_interp(t):
        if t > 2:
            raise ValueError("Out of bounds")
        else:
            return t

    denseoutput.add_interpolant(3, new_interp)
コード例 #4
0
def test_dense_add_outofbounds():
    with pytest.raises(ValueError):
        inputs = D.array([0, 1, 0, 1, 1, 1])
        interpolator = CubicHermiteInterp(*inputs)
        denseoutput = DenseOutput([0, 1], [interpolator])

        def new_interp(t):
            if t < 2:
                raise ValueError("Out of bounds")
            else:
                return t

        denseoutput.add_interpolant(2, new_interp)
コード例 #5
0
def test_dense_add_noncallable():
    with pytest.raises(TypeError):
        inputs = D.array([0, 1, 0, 1, 1, 1])
        interpolator = CubicHermiteInterp(*inputs)
        denseoutput = DenseOutput([0, 1], [interpolator])
        denseoutput.add_interpolant(2, None)
コード例 #6
0
def test_dense_init_add_prefix():
    denseoutput = DenseOutput(None, None)
    inputs = D.array([-1, 0, 0, 1, 1, 1])
    interpolator = CubicHermiteInterp(*inputs)
    denseoutput.add_interpolant(-1, interpolator)