def test_extrapolation_interface():
    """Test the extrapolation module interface."""

    from pysteps import extrapolation
    from pysteps.extrapolation import semilagrangian

    from pysteps.extrapolation.interface import eulerian_persistence as eulerian
    from pysteps.extrapolation.interface import _do_nothing as do_nothing

    method_getter = extrapolation.interface.get_method

    valid_returned_objs = dict()
    valid_returned_objs["semilagrangian"] = semilagrangian.extrapolate
    valid_returned_objs["eulerian"] = eulerian
    valid_returned_objs[None] = do_nothing
    valid_returned_objs["None"] = do_nothing

    valid_names_func_pair = list(valid_returned_objs.items())

    invalid_names = ["euler", "LAGRANGIAN"]
    _generic_interface_test(method_getter, valid_names_func_pair, invalid_names)

    # Test eulerian persistence method
    precip = numpy.random.rand(100, 100)
    velocity = numpy.random.rand(100, 100)
    num_timesteps = 10
    for name in ["eulerian", "EULERIAN"]:
        forecaster = method_getter(name)
        forecast = forecaster(precip, velocity, num_timesteps)
        for i in range(num_timesteps):
            assert numpy.all(forecast[i] == precip)

    forecaster = method_getter(None)
    assert forecaster(precip, velocity, num_timesteps) is None
Test the extrapolation module interface.
pysteps/tests/test_interfaces.py