Ejemplo n.º 1
0
def test_scipy_limits(pars, method):
    ds = MyDataset(pars)
    pars["y"].min = 301000

    factors, info, minuit = optimize_scipy(
        function=ds.fcn, parameters=pars, method=method
    )

    assert info["success"]

    # Check the result in parameters is OK
    assert_allclose(pars["x"].value, 2, rtol=1e-2)
    assert_allclose(pars["y"].value, 301000, rtol=1e-3)
Ejemplo n.º 2
0
def test_scipy_basic(pars, method):
    ds = MyDataset(pars)
    factors, info, optimizer = optimize_scipy(
        function=ds.fcn, parameters=pars, method=method
    )

    assert info["success"]
    assert_allclose(ds.fcn(), 0, atol=1e-5)

    # Check the result in parameters is OK
    assert_allclose(pars["x"].value, 2, rtol=1e-3)
    assert_allclose(pars["y"].value, 3e5, rtol=1e-3)
    assert_allclose(pars["z"].value, 4e-5, rtol=2e-2)
Ejemplo n.º 3
0
def test_scipy_frozen(pars, method):
    ds = MyDataset(pars)
    pars["y"].frozen = True

    factors, info, optimizer = optimize_scipy(
        function=ds.fcn, parameters=pars, method=method
    )

    assert info["success"]

    assert_allclose(pars["x"].value, 2, rtol=1e-4)
    assert_allclose(pars["y"].value, 3.1e5)
    assert_allclose(pars["z"].value, 4.0e-5, rtol=1e-4)
    assert_allclose(ds.fcn(), 0.1111111, rtol=1e-5)
Ejemplo n.º 4
0
def test_scipy_confidence(pars):
    ds = MyDataset(pars)
    factors, info, _ = optimize_scipy(function=ds.fcn, parameters=pars)

    assert_allclose(ds.fcn(), 0, atol=1e-5)

    par = pars["x"]
    par.min, par.max = 0, 10

    result = confidence_scipy(function=ds.fcn, parameters=pars, parameter=par, sigma=1)

    assert result["success_errp"]
    assert result["success_errn"]

    assert_allclose(result["errp"], 0.2, rtol=1e-3)
    assert_allclose(result["errn"], 0.2, rtol=1e-3)