Ejemplo n.º 1
0
def test_optimization_result_try_get_final_datasets_for_successful_optimization(
) -> None:
    data = {"foo": empty_dataset([1], [1])}
    result: OptimizationResult[None] = OptimizationResult(
        Ok(Record(data, {"foo": _PseudoTrainableQuadratic()}, None)), [])
    assert result.try_get_final_datasets() is data
    assert result.try_get_final_dataset() is data["foo"]
Ejemplo n.º 2
0
def test_optimization_result_try_get_final_models_for_successful_optimization(
) -> None:
    models = {"foo": _PseudoTrainableQuadratic()}
    result: OptimizationResult[None] = OptimizationResult(
        Ok(Record({"foo": empty_dataset([1], [1])}, models, None)), [])
    assert result.try_get_final_models() is models
    assert result.try_get_final_model() is models["foo"]
Ejemplo n.º 3
0
def test_optimization_result_try_get_final_models_for_multiple_models() -> None:
    data = {"foo": empty_dataset([1], [1]), "bar": empty_dataset([2], [2])}
    models = {"foo": _PseudoTrainableQuadratic(), "bar": _PseudoTrainableQuadratic()}
    result: OptimizationResult[None] = OptimizationResult(Ok(Record(data, models, None)), [])
    assert result.try_get_final_models() is models
    with pytest.raises(ValueError):
        result.try_get_final_model()