Datasets

When a frankford.Fitter object is created the models parameter is a dict whose values are functions that take parameters and independent variables as arguments. A model must return a double when all arguments are type double. Further, it must conform to the requirements laid out in the numba documentation for cuda device functions.

If a model raises a python error the result for the fit is frankford.Result.ERR_USER_FUNC. Returning a non-finite (\(\pm \infty\) or not-a-number (NaN)) value has the same result.

The frankford.Dataset class is used to pass data used in the fit to the frankford.Fitter object when it is called. One frankford.Dataset is passed for each model in the models parameters passed to __init__. The keys in this object must be the same as the models dict used when the frankford.Fitter was created.

class frankford.Dataset(points, axis, ind_vars)

Represent data to fit to a model.

__init__(points, axis, ind_vars)
Parameters:
  • points (numpy array of frankford.point_dtype) – Dependent values along with uncertainties

  • axis (int | tuple of int) – Axis or axes along which a fit is performed. If axis is negative it counts from the last to the first axis. If axis is a tuple of ints, a fit is performed on all of the axes specified in the tuple instead of a single axis.

  • ind_vars (dict of str to numpy array) – dict of arrays repressing the independent variables to be passed to the model

The points array must be a numpy array with dtype frankford.point_dtype. This dtype has two np.double fields. value stores the value to be fitted to and uncertainty stores the uncertainty of that value.

The output shape of the data set is the shape of the points array with the axes in axis eliminated. For example if the shape of the array is (2, 3, 4, 5) and axis is (0, 2), the output shape is (3, 5). The output shape will be the shape of the output array. All data sets must have the same output shape.

Each independent variable array must have the same shape as the points array or the shape of the points array with only the axes specified. For example, if the shape of the array is (2, 3, 4, 5) and axis is (0, 2), the each independent variable array must have shape (2, 3, 4, 5) or (2, 4).

Points whose value is not-a-number (NaN) are ignored by the fitter. The number of remaining points is reflected in the fit’s degrees of freedom returned. If there are more free parameters than remaining points, the fit is invalid and the return value has a result of frankford.Result.ERR_DOF.

The keys in the ind_vars dict must be strings that match arguments in the model function.