示例#1
0
def function_cases(odr_mock, request):
    func, kwargs, model_extra_kwargs, fit_a0 = (
        request.param["func"],
        request.param.get("kwargs", {}),
        request.param.get("model_extra_kwargs", {}),
        request.param.get("a0", a0),
    )
    data = FittingData.random(fit_func=func)
    result = fit(data=data, func=func, a0=fit_a0, **kwargs)
    return dict(
        func=func,
        data=data,
        result=result,
        model_extra_kwargs=model_extra_kwargs,
        a0=fit_a0,
        mocks=odr_mock,
    )
示例#2
0
def random_fitting_data(mocker, fitting_arguments, random_sigma_mock,
                        random_error_mock):
    random_array_mock = mocker.patch("eddington.fitting_data.random_array")
    random_array_side_effect = []
    if "a" not in fitting_arguments:
        random_array_side_effect.append(a)
    if "x" not in fitting_arguments:
        random_array_side_effect.append(x)
    random_array_mock.side_effect = random_array_side_effect
    return (
        FittingData.random(dummy_func1, **fitting_arguments),
        dict(
            params=fitting_arguments,
            random_array=random_array_mock,
            random_sigma=random_sigma_mock,
            random_error=random_error_mock,
        ),
    )
示例#3
0
HAS_LEGEND = "has_legend"
DOES_NOT_HAVE_LEGEND = "does_not_have_legend"

EPSILON = 1e-5

FUNC = linear
X = np.arange(1, 11)
A1, A2, A3 = np.array([1, 1]), np.array([3,
                                         2]), np.array([3.924356, 1.2345e-5])
A1_REPR, A2_REPR, A3_REPR = (
    "[a[0]=1.000, a[1]=1.000]",
    "[a[0]=3.000, a[1]=2.000]",
    "[a[0]=3.924, a[1]=1.234e-05]",
)
FIT_DATA = FittingData.random(FUNC,
                              x=X,
                              a=np.array([1, 2]),
                              measurements=X.shape[0])
TITLE_NAME = "Title"


@case(tags=[DOES_NOT_HAVE_LEGEND])
def case_no_args(mock_figure):
    x = np.arange(0.1, 10.9, step=0.0108)

    kwargs = dict(a=A1)
    plot_calls = [([x, FUNC(A1, x)], dict(label=A1_REPR))]
    return kwargs, plot_calls, mock_figure


@case(tags=[DOES_NOT_HAVE_LEGEND])
def case_xmin(mock_figure):
示例#4
0
def make_data():
    data = FittingData.random(linear, a=a)
    return data, data.residuals(linear, a)
示例#5
0
import numpy as np

from eddington import FittingData, linear, plot_data, plot_fitting, plot_residuals

FUNC = linear
X = np.arange(1, 11)
A = np.array([1, 2])
FIT_DATA = FittingData.random(FUNC, x=X, a=A, measurements=X.shape[0])
TITLE_NAME = "Title"


def case_plot_data():
    return dict(data=FIT_DATA, title_name=TITLE_NAME), plot_data


def case_plot_fitting():
    return dict(func=FUNC, data=FIT_DATA, a=A,
                title_name=TITLE_NAME), plot_fitting


def case_plot_residuals():
    return dict(func=FUNC, data=FIT_DATA, a=A,
                title_name=TITLE_NAME), plot_residuals