Exemplo n.º 1
0
def test_positive_calculation_order():
    value, lower = -10.0, 10.0
    expected = np.exp(value) + lower
    with as_context(Config(positive_bijector="exp", positive_minimum=lower)):
        result = positive()(value).numpy()
    assert np.isclose(result, expected)
    assert result >= lower
Exemplo n.º 2
0
def test_positive_lower(env_lower, override_lower):
    expected_lower = override_lower or env_lower
    with as_context(
            Config(positive_bijector="softplus", positive_minimum=env_lower)):
        bijector = positive(lower=override_lower)
        assert isinstance(bijector, tfp.bijectors.Chain)
        assert np.isclose(bijector.bijectors[0].shift, expected_lower)
Exemplo n.º 3
0
def test_positive_bijector(env_bijector, override_bijector, expected_class):
    with as_context(
            Config(positive_bijector=env_bijector, positive_minimum=None)):
        bijector = positive(base=override_bijector)
        assert isinstance(bijector, expected_class)
Exemplo n.º 4
0
def test_print_summary_output_string_with_positive_minimum():
    with as_context(Config(positive_minimum=1e-6)):
        print(tabulate_module_summary(create_kernel()))
        assert tabulate_module_summary(
            create_kernel()) == kernel_param_print_string_with_shift
Exemplo n.º 5
0
def test_print_summary_output_string(module_callable,
                                     expected_param_print_string):
    with as_context(Config(positive_minimum=None)):
        assert tabulate_module_summary(
            module_callable()) == expected_param_print_string