Ejemplo n.º 1
0
def test_iteration_warnings():
    """Test that the correct warning is raised beyond the iteration limit."""
    fac = LinearFactory(X_VALS)
    with warns(
        ConvergenceWarning,
        match=r"Factory iteration loop stopped before convergence.",
    ):
        fac.iterate(lambda scale_factor: 1.0, max_iterations=3)
Ejemplo n.º 2
0
def test_linear_extr():
    """Tests extrapolation with a LinearFactory."""
    seeded_f = apply_seed_to_func(f_lin, SEED)
    fac = LinearFactory(X_VALS)
    assert fac.opt_params == []
    fac.iterate(seeded_f)
    assert np.isclose(fac.reduce(), seeded_f(0, err=0), atol=CLOSE_TOL)
    assert np.allclose(fac.opt_params, [B, A], atol=CLOSE_TOL)