Exemple #1
0
def test_microdistancing__with_tanh_func_and_adjuster():
    params = {
        "foo": {
            "function_type": "tanh",
            "parameters": {
                "shape": -0.05,
                "inflection_time": 275,
                "lower_asymptote": 0.6,
                "upper_asymptote": 1,
            },
            "locations": LOCATIONS,
        },
        "foo_adjuster": {
            "function_type": "empiric",
            "parameters": {
                "max_effect": 0.6,
                "times": [0, 365],
                "values": [1, 100],
            },
            "locations": LOCATIONS,
        },
    }
    expect_func = tanh_based_scaleup(**params["foo"]["parameters"])
    expect_adj_func = scale_up_function([0, 365], [0.6, 60], method=4)
    params = {k: MicroDistancingFunc(**v) for k, v in params.items()}
    funcs = get_microdistancing_funcs(params=params, square_mobility_effect=False)
    assert funcs["work"](0) == 1 - expect_func(0) * expect_adj_func(0)
    assert funcs["home"](0) == 1 - expect_func(0) * expect_adj_func(0)
    assert funcs["work"](300) == 1 - expect_func(300) * expect_adj_func(300)
    assert funcs["home"](300) == 1 - expect_func(300) * expect_adj_func(300)
Exemple #2
0
def test_microdistancing__with_empiric_func():
    params = {
        "foo": {
            "function_type": "empiric",
            "parameters": {
                "max_effect": 0.6,
                "times": [0, 365],
                "values": [1, 100],
            },
            "locations": LOCATIONS,
        }
    }
    expect_func = scale_up_function([0, 365], [0.6, 60], method=4)
    params = {k: MicroDistancingFunc(**v) for k, v in params.items()}
    funcs = get_microdistancing_funcs(params=params, square_mobility_effect=False)
    assert funcs["work"](0) == 1 - expect_func(0)
    assert funcs["home"](0) == 1 - expect_func(0)
    assert funcs["work"](300) == 1 - expect_func(300)
    assert funcs["home"](300) == 1 - expect_func(300)
Exemple #3
0
def test_microdistancing__with_tanh_func_and_square_mobility_effect():
    params = {
        "foo": {
            "function_type": "tanh",
            "parameters": {
                "shape": -0.05,
                "inflection_time": 275,
                "lower_asymptote": 0.6,
                "upper_asymptote": 1,
            },
            "locations": LOCATIONS,
        }
    }

    expect_func = tanh_based_scaleup(**params["foo"]["parameters"])
    params = {k: MicroDistancingFunc(**v) for k, v in params.items()}
    funcs = get_microdistancing_funcs(params=params, square_mobility_effect=True)
    assert funcs["work"](0) == (1 - expect_func(0)) ** 2
    assert funcs["home"](0) == (1 - expect_func(0)) ** 2
    assert funcs["work"](300) == (1 - expect_func(300)) ** 2
    assert funcs["home"](300) == (1 - expect_func(300)) ** 2
Exemple #4
0
def test_microdistancing__with_no_funcs():
    funcs = get_microdistancing_funcs(params={}, square_mobility_effect=False)
    assert funcs["work"](0) == 1
    assert funcs["home"](0) == 1