def test_raise_exception_for_observable_with_one_value(observables):
    point_constr = {"observables": observables}
    params, _ = generate_random_model(point_constr=point_constr)

    params = params.drop(index="observable_observable_0_0", level="category")["value"]

    with pytest.raises(ValueError, match=r"Observables and exogenous processes"):
        _parse_observables({}, params)
def test_parse_observables():
    params = pd.read_csv(
        io.StringIO(
            textwrap.dedent(
                """
                category,name,value
                observable_fishing_grounds_rich_grounds,probability,0.5
                observable_fishing_grounds_poor_grounds,probability,0.5
                observable_ability_low_middle,probability,0.5
                observable_ability_high,probability,0.5
                """
            )
        ),
        index_col=["category", "name"],
    )["value"]
    optim_paras = _parse_exogenous_processes({}, params)
    optim_paras = _parse_observables(optim_paras, params)

    expected = {
        "fishing_grounds": {
            "rich_grounds": pd.Series(data=np.log(0.5), index=["constant"]),
            "poor_grounds": pd.Series(data=np.log(0.5), index=["constant"]),
        },
        "ability": {
            "low_middle": pd.Series(data=np.log(0.5), index=["constant"]),
            "high": pd.Series(data=np.log(0.5), index=["constant"]),
        },
    }

    for observable, level_dict in optim_paras["observables"].items():
        for level in level_dict:
            assert optim_paras["observables"][observable][level].equals(
                expected[observable][level]
            )