Parameters and Objects
Descriptors
Parameters
Super Classes and Collections
Super Classes
Collections
- class easyCore.Objects.Groups.BaseCollection(name, *args, interface=None, **kwargs)[source]
Set up the base collection class.
- Parameters:
- append(value)
S.append(value) – append value to the end of the sequence
- as_data_dict(skip=None)
Returns a dictionary containing just the data of an easyCore object.
- as_dict(skip=None)
Convert an easyCore object into a full dictionary using DictSerializer. This is a shortcut for
`obj.encode(encoder=DictSerializer)`
- clear() None -- remove all items from S
- count(value) integer -- return number of occurrences of value
- property data: Tuple
The data function returns a tuple of the keyword arguments passed to the constructor. This is useful for when you need to pass in a dictionary of data to other functions, such as with matplotlib’s plot function.
- Parameters:
self – Access attributes of the class within the method
- Return type:
- Returns:
The values of the attributes in a tuple
- Doc-author:
Trelent
- classmethod decode(obj, decoder=None)
Re-create an easyCore object from the output of an encoder. The default decoder is DictSerializer.
- Parameters:
obj (Any) – encoded easyCore object
decoder (Optional[EC]) – decoder to be used to reform the easyCore object
- Return type:
Any
- Returns:
Reformed easyCore object
- encode(skip=None, encoder=None, **kwargs)
Use an encoder to covert an easyCore object into another format. Default is to a dictionary using DictSerializer.
- Parameters:
skip (Optional[List[str]]) – List of field names as strings to skip when forming the encoded object
encoder (Optional[EC]) – The encoder to be used for encoding the data. Default is DictSerializer
kwargs – Any additional key word arguments to be passed to the encoder
- Return type:
Any
- Returns:
encoded object containing all information to reform an easyCore object.
- encode_data(skip=None, encoder=None, **kwargs)
Returns just the data in an easyCore object win the format specified by an encoder.
- Parameters:
skip (Optional[List[str]]) – List of field names as strings to skip when forming the dictionary
encoder (Optional[EC]) – The encoder to be used for encoding the data. Default is DataDictSerializer
kwargs – Any additional keywords to pass to the encoder when encoding
- Return type:
Any
- Returns:
encoded object containing just the data of an easyCore object.
- extend(values)
S.extend(iterable) – extend sequence by appending elements from the iterable
- classmethod from_dict(obj_dict)
Re-create an easyCore object from a full encoded dictionary.
- generate_bindings()
Generate or re-generate bindings to an interface (if exists)
- Raises:
AttributeError
- get_fit_parameters()
Get all objects which can be fitted (and are not fixed) as a list.
- Return type:
List
[Parameter
]- Returns:
List of Parameter objects which can be used in fitting.
- get_parameters()
Get all parameter objects as a list.
- Return type:
List
[Parameter
]- Returns:
List of Parameter objects.
- index(value[, start[, stop]]) integer -- return first index of value.
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- insert(index, value)[source]
Insert an object into the collection at an index.
- Parameters:
index (int) – Index for easyCore object to be inserted.
value (Union[BasedBase, Descriptor]) – Object to be inserted.
- Returns:
None
- Return type:
None
- property interface: iF
Get the current interface of the object
- Return type:
iF
- property name: str
Get the common name of the object.
- Return type:
- Returns:
Common name of the object
- pop([index]) item -- remove and return item at index (default last).
Raise IndexError if list is empty or index is out of range.
- remove(value)
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- reverse()
S.reverse() – reverse IN PLACE
- sort(mapping, reverse=False)[source]
Sort the collection according to the given mapping.
- Parameters:
mapping (Callable) – mapping function to sort the collection. i.e. lambda parameter: parameter.raw_value
reverse (bool) – Reverse the sorting.
- Return type:
None
- switch_interface(new_interface_name)
Switch or create a new interface.
- unsafe_hash()
Returns an hash of the current object. This uses a generic but low performance method of converting the object to a dictionary, flattening any nested keys, and then performing a hash on the resulting object
- Return type:
openssl_sha1
Data Containers
- class easyCore.Datasets.xarray.easyCoreDataarrayAccessor(xarray_obj)[source]
Accessor to extend an xarray DataArray to easyCore. These functions can be accessed by obj.easyCore.func.
- property compute_func: Callable
Get the computational function which will be executed during a fit
- Returns:
Computational function applied to the DataArray
- Return type:
Callable
- property core_object
Get the core object associated to a DataArray. Note that this is called from a weakref. If the easyCore obj is garbage collected, None will be returned.
- Returns:
easyCore object associated with the DataArray
- Return type:
Any
- fit(fitter, *args, fit_kwargs=None, fn_kwargs=None, vectorize=False, dask='forbidden', **kwargs)[source]
Perform a fit on the given DataArray. This fit utilises a given fitter from easyCore.Fitting.Fitter, though there are a few differences to a standard easyCore fit. In particular, key-word arguments to control the optimisation algorithm go in the fit_kwargs dictionary, fit function key-word arguments go in the fn_kwargs and given key-word arguments control the xarray.apply_ufunc function.
- Parameters:
fitter (easyCore.Fitting.Fitter) – Fitting object which controls the fitting
args (Any) – Arguments to go to the fit function
dask (str) – Dask control string. See xarray.apply_ufunc documentation
fit_kwargs (dict) – Dictionary of key-word arguments to be supplied to the Fitting control
fn_kwargs (dict) – Dictionary of key-words to be supplied to the fit function
vectorize (bool) – Should the fit function be given dependents in a single object or split
kwargs (Any) – Key-word arguments for xarray.apply_ufunc. See xarray.apply_ufunc documentation
- Returns:
Results of the fit
- Return type:
FitResults
- fit_prep(func_in, bdims=None, dask_chunks=None)[source]
Generate boradcasted coordinates for fitting and reform the fitting function into one which can handle xarrays
- Parameters:
func_in (Callable) – Function to be wrapped and made xarray fitting compatable.
bdims (xarray.DataArray) – Optional precomputed broadcasted dimensions.
dask_chunks (Tuple[int..]) – How to split to broadcasted dimensions for dask.
- Returns:
Tuple of broadcasted fit arrays and wrapped fit function.
- Return type:
xarray.DataArray, Callable
- generate_points()[source]
Generate an expanded DataArray of points which corresponds to broadcasted dimensions (all_x) which have been concatenated along the second axis (fit_dim).
- Returns:
Broadcasted and concatenated coordinates
- Return type:
- class easyCore.Datasets.xarray.easyCoreDatasetAccessor(xarray_obj)[source]
This is called whenever you access obj.easyCore, hence the attributes in the obj should only be written if they have not been previously instantiated.
- Parameters:
xarray_obj (xarray.Dataset) – DataSet which is called by obj.easyCore
- add_coordinate(coordinate_name, coordinate_values, unit='')[source]
Add a coordinate to the DataSet. This can be then be assigned to one or more DataArrays.
- add_variable(variable_name, variable_coordinates, variable_values, variable_sigma=None, unit='', auto_sigma=False)[source]
Create a DataArray from known coordinates and data, assign it to the dataset under a given name. Variances can be calculated assuming gaussian distribution to 1 sigma.
- Parameters:
variable_name (str) – Name of the DataArray which will be created and added to the dataset
variable_coordinates (str, List[str]) – List of coordinates used in the supplied data array.
variable_values (Union[numpy.ndarray, list]) – Numpy or list of data which will be assigned to the DataArray
variable_sigma (Union[numpy.ndarray, list]) – If the sigmas of the dataset are known, they can be supplied here.
unit (str) – Unit associated with the DataArray
auto_sigma (bool) – Should the sigma DataArray be automatically calculated assuming gaussian probability?
- Returns:
None
- Return type:
None
- property core_object
Get the core object associated to a DataSet. Note that this is called from a weakref. If the easyCore obj is garbage collected, None will be returned.
- Returns:
easyCore object associated with the DataSet
- Return type:
Any
- property description: str
Get a description of the DataSet
- Returns:
Description of the DataSet
- Return type:
- fit(fitter, data_arrays, *args, dask='forbidden', fit_kwargs=None, fn_kwargs=None, vectorized=False, **kwargs)[source]
Perform a fit on one or more DataArrays. This fit utilises a given fitter from easyCore.Fitting.Fitter, though there are a few differences to a standard easyCore fit. In particular, key-word arguments to control the optimisation algorithm go in the fit_kwargs dictionary, fit function key-word arguments go in the fn_kwargs and given key-word arguments control the xarray.apply_ufunc function.
- Parameters:
fitter (easyCore.Fitting.Fitter) – Fitting object which controls the fitting
args (Any) – Arguments to go to the fit function
dask (str) – Dask control string. See xarray.apply_ufunc documentation
fit_kwargs (dict) – Dictionary of key-word arguments to be supplied to the Fitting control
fn_kwargs (dict) – Dictionary of key-words to be supplied to the fit function
vectorized (bool) – Should the fit function be given dependents in a single object or split
kwargs (Any) – Key-word arguments for xarray.apply_ufunc. See xarray.apply_ufunc documentation
- Returns:
Results of the fit
- Return type:
List[FitResults]
- generate_points(coordinates)[source]
Generate an expanded DataArray of points which corresponds to broadcasted dimensions (all_x) which have been concatenated along the second axis (fit_dim).
- param coordinates:
List of coordinate names to broadcast and concatenate along
- type coordinates:
List[str]
- return:
Broadcasted and concatenated coordinates
- rtype:
xarray.DataArray
x = [1, 2], y = [3, 4] d = xr.DataArray() d.easyCore.add_coordinate('x', x) d.easyCore.add_coordinate('y', y) points = d.easyCore.generate_points(['x', 'y']) print(points)
- Return type:
- property name: str
Get the common name of the DataSet.
- Returns:
Common name of the DataSet
- Return type:
- remove_coordinate(coordinate_name)[source]
Remove a coordinate from the DataSet. Note that this will not remove the coordinate from DataArrays which have already used the it!
- Parameters:
coordinate_name (str) – Name of the coordinate to be removed
- Returns:
None
- Return type:
None
- remove_variable(variable_name)[source]
Remove a DataArray from the DataSet by supplied name.
- Parameters:
variable_name (str) – Name of DataArray to be removed
- Returns:
None
- Return type:
None
- sigma_attach(variable_label, sigma_values, label_prefix=None)[source]
Attach an array of sigmas to the DataSet.
- Parameters:
- Returns:
None
- Return type:
None
- sigma_generator(variable_label, sigma_func=<function easyCoreDatasetAccessor.<lambda>>, label_prefix=None)[source]
Generate sigmas off of a DataArray based on a function.
- Parameters:
shape as the input. DEFAULT: sqrt(|data|) :type sigma_func: Callable :type label_prefix:
Optional
[str
] :param label_prefix: What prefix should be used to designate a sigma DataArray from a data DataArray :type label_prefix: str :return: None :rtype: None