Пример #1
0
def test_BayesProportionsEstimation_with_a_bad_proportion_returns_ValueError(
        make_a_bad_proportion, make_b_list):
    with pytest.raises(ValueError) as e:
        BayesProportionsEstimation(a=make_a_bad_proportion, b=make_b_list)
    assert (str(
        e.value
    ) == "the count of successes for a and/or b exceeds the number of trials")
Пример #2
0
def test_BayesProportionsEstimation_with_make_invalid_seed_returns_ValueError(
        make_a_list, make_b_list, make_invalid_seed):
    with pytest.raises(ValueError) as e:
        BayesProportionsEstimation(a=make_a_list,
                                   b=make_b_list,
                                   seed=make_invalid_seed)
    assert str(e.value) == "seed must be a positive integer or None"
Пример #3
0
def test_plot_posterior_with_error(make_a_list, make_b_list,
                                   make_explicit_seed):
    try:
        BayesProportionsEstimation(a=make_a_list,
                                   b=make_b_list,
                                   seed=make_explicit_seed).posterior_plot()
    except:
        raise pytest.fail()
Пример #4
0
def test_infer_delta_bayes_factor_returns_correct_values(
        make_a_list, make_b_list, make_explicit_seed,
        make_infer_delta_bayes_factor_result):
    bf, i = BayesProportionsEstimation(
        a=make_a_list, b=make_b_list,
        seed=make_explicit_seed).infer_delta_bayes_factor()
    assert np.isclose(bf, make_infer_delta_bayes_factor_result[0])
    assert i == make_infer_delta_bayes_factor_result[1]
Пример #5
0
def test_infer_delta_probability_returns_correct_values(
        make_a_list, make_b_list, make_explicit_seed,
        make_infer_delta_probability_result):
    p, i = BayesProportionsEstimation(
        a=make_a_list, b=make_b_list,
        seed=make_explicit_seed).infer_delta_probability()
    assert np.isclose(p, make_infer_delta_probability_result[0])
    assert i == make_infer_delta_probability_result[1]
Пример #6
0
def test_BayesProportionsEstimation_quantile_summary_returns_correct_results(
        make_a_list, make_b_list, make_explicit_seed,
        make_quantile_summary_results):
    test = np.array(
        BayesProportionsEstimation(
            a=make_a_list, b=make_b_list,
            seed=make_explicit_seed).quantile_summary())[:, 0:3]
    assert np.array_equal(test, make_quantile_summary_results)
Пример #7
0
def test_BayesProportionsEstimation_with_make_invalid_prior_returns_ValueError(
        make_a_list, make_b_list, make_invalid_prior):
    with pytest.raises(ValueError) as e:
        BayesProportionsEstimation(a=make_a_list,
                                   b=make_b_list,
                                   prior_alpha=make_invalid_prior)
    assert str(
        e.value) == "the prior_alpha and/or prior_beta parameters must be > 0"
Пример #8
0
def test_BayesProportionsEstimation_with_a_str_returns_ValueError(
        make_a_str, make_b_list):
    with pytest.raises(ValueError) as e:
        BayesProportionsEstimation(a=make_a_str, b=make_b_list)
    assert (
        str(e.value) ==
        "type(a).__name__ and/or type(b).__name__ must be 'list', 'ndarray' or 'DataFrame'"
    )
Пример #9
0
def test_BayesProportionsEstimation_with_mmake_explicit_seed_initialises(
        make_a_list, make_b_list, make_explicit_seed):
    try:
        BayesProportionsEstimation(a=make_a_list,
                                   b=make_b_list,
                                   seed=make_explicit_seed)
    except:
        raise pytest.fail()
Пример #10
0
def test_BayesProportionsEstimation_with_make_explicit_prior_alpha_and_make_explicit_prior_beta_intialises(
        make_a_list, make_b_list, make_explicit_prior):
    try:
        BayesProportionsEstimation(a=make_a_list,
                                   b=make_b_list,
                                   prior_alpha=make_explicit_prior)
    except:
        raise pytest.fail()
Пример #11
0
def test_BayesProportionsEstimation_get_posteriors_returns_correct_results(
    make_a_list,
    make_b_list,
    make_explicit_n,
    make_explicit_seed,
    make_get_posterior_results,
):
    test = BayesProportionsEstimation(
        make_a_list, make_b_list, n=make_explicit_n,
        seed=make_explicit_seed).get_posteriors()
    test = np.array(pd.DataFrame(test))
    assert np.allclose(test, make_get_posterior_results)
Пример #12
0
def test_BayesProportionsEstimation_with_make_a_series_and_make_b_series_initialises(
        make_a_series, make_b_series):
    try:
        BayesProportionsEstimation(a=make_a_series, b=make_b_series)
    except:
        raise pytest.fail()
Пример #13
0
def test_BayesProportionsEstimation_with_make_a_numpy_and_make_b_numpy_initialises(
        make_a_numpy, make_b_numpy):
    try:
        BayesProportionsEstimation(a=make_a_numpy, b=make_b_numpy)
    except:
        raise pytest.fail()
Пример #14
0
def test_BayesProportionsEstimation_with_make_a_list_and_make_b_list_initialises(
        make_a_list, make_b_list):
    try:
        BayesProportionsEstimation(a=make_a_list, b=make_b_list)
    except:
        raise pytest.fail()