def test_eval_1d_non_uniform_vec(variant_packet_rgb):
    from mitsuba.core import spline

    assert (ek.allclose(spline.eval_1d(nodes1, values2, input1), input1))
    assert (ek.allclose(spline.eval_1d(nodes1, values2, input2), input2))
    assert (ek.allclose(spline.eval_1d(nodes2, values2, 2 * input1), input1))
    assert (ek.allclose(spline.eval_1d(nodes2, values2, 2 * input2), input2))
def test_eval_1d_uniform(variant_scalar_rgb):
    from mitsuba.core import spline

    assert (ek.allclose(spline.eval_1d(0, 1, values1, 0), 0))
    assert (ek.allclose(spline.eval_1d(0, 1, values1, 0.5), 0.5))
    assert (ek.allclose(spline.eval_1d(0, 1, values1, 1), 1))
    assert (ek.allclose(spline.eval_1d(0, 1, values2, 0.2), 0.2))
    assert (ek.allclose(spline.eval_1d(0, 1, values2, 0.8), 0.8))
def test_invert_1d(variant_scalar_rgb):
    from mitsuba.core import spline

    values = Float([0.0, 0.25, 0.5, 0.75, 1.0])
    assert (ek.allclose(
        spline.invert_1d(0, 1, values, spline.eval_1d(0, 1, values, 0.6)),
        0.6))
    values = Float([0.1, 0.2, 0.3, 0.35, 1])
    assert (ek.allclose(
        spline.invert_1d(0, 1, values, spline.eval_1d(0, 1, values, 0.26)),
        0.26))
    assert (ek.allclose(
        spline.invert_1d(0, 1, values, spline.eval_1d(0, 1, values, 0.46)),
        0.46))
    assert (ek.allclose(
        spline.invert_1d(0, 1, values, spline.eval_1d(0, 1, values, 0.86)),
        0.86))