def test_multinomial_model_fit():
    """Test borg.models.MultinomialModel.fit()."""

    runs = [
        ("solver_a", 100.0, 1.0, True),
        ("solver_a", 100.0, 48.0, True),
        ("solver_a", 100.0, 100.0, False),
        ("solver_b", 100.0, 66.0, True),
        ("solver_b", 100.0, 77.0, True),
        ("solver_b", 100.0, 100.0, False),
        ]

    training = borg.RunData()

    for run in runs:
        training.add_run("foo", borg.storage.RunRecord(*run))
        training.add_run("bar", borg.storage.RunRecord(*run))

    alpha = 1.0 + 1e-8
    model = borg.models.MultinomialModel.fit(["solver_a", "solver_b"], training, 4, alpha)
    components = numpy.exp(model.log_components)

    nose.tools.assert_true(numpy.all(numpy.abs(components[0] - components[1]) == 0.0))
    nose.tools.assert_true(numpy.all(numpy.abs(1.0 - numpy.sum(components, axis = -1)) < 1e-10))
    nose.tools.assert_true(numpy.all(components[:, 0, 0] == components[:, 0, 1]))
    nose.tools.assert_true(numpy.all(components[:, 0, 1] > components[:, 0, 2]))
    nose.tools.assert_true(numpy.all(components[:, 1, 0] == components[:, 1, 1]))
    nose.tools.assert_true(numpy.all(components[:, 1, 1] < components[:, 1, 2]))
dataset/ETHPy150Open borg-project/borg/borg/test/test_models.py/test_multinomial_model_fit/swapped operands of `-`