docstrings extended

This commit is contained in:
Fabian Joswig 2021-11-01 14:41:57 +00:00
parent bb07ce9cef
commit ebba71075a
2 changed files with 82 additions and 40 deletions

View file

@ -15,6 +15,14 @@ from .pyerrors import Obs, derived_observable, covariance, pseudo_Obs
class Fit_result(Sequence): class Fit_result(Sequence):
"""Represents fit results.
Attributes
----------
fit_parameters : list
results for the individual fit parameters,
also accesible via indices.
"""
def __init__(self): def __init__(self):
self.fit_parameters = None self.fit_parameters = None

View file

@ -24,16 +24,21 @@ class Obs:
Attributes Attributes
---------- ----------
e_tag_global -- Integer which determines which part of the name belongs e_tag_global : int
to the ensemble and which to the replicum. Integer which determines which part of the name belongs
S_global -- Standard value for S (default 2.0) to the ensemble and which to the replicum.
S_dict -- Dictionary for S values. If an entry for a given ensemble S_global : float
exists this overwrites the standard value for that ensemble. Standard value for S (default 2.0)
tau_exp_global -- Standard value for tau_exp (default 0.0) S_dict : dict
tau_exp_dict -- Dictionary for tau_exp values. If an entry for a given Dictionary for S values. If an entry for a given ensemble
ensemble exists this overwrites the standard value for that exists this overwrites the standard value for that ensemble.
ensemble. tau_exp_global : float
N_sigma_global -- Standard value for N_sigma (default 1.0) Standard value for tau_exp (default 0.0)
tau_exp_dict :dict
Dictionary for tau_exp values. If an entry for a given ensemble exists
this overwrites the standard value for that ensemble.
N_sigma_global : float
Standard value for N_sigma (default 1.0)
""" """
__slots__ = ['names', 'shape', 'r_values', 'deltas', 'N', '_value', '_dvalue', __slots__ = ['names', 'shape', 'r_values', 'deltas', 'N', '_value', '_dvalue',
'ddvalue', 'reweighted', 'S', 'tau_exp', 'N_sigma', 'e_names', 'ddvalue', 'reweighted', 'S', 'tau_exp', 'N_sigma', 'e_names',
@ -50,6 +55,20 @@ class Obs:
filter_eps = 1e-10 filter_eps = 1e-10
def __init__(self, samples, names, idl=None, means=None, **kwargs): def __init__(self, samples, names, idl=None, means=None, **kwargs):
""" Initialize Obs object.
Attributes
----------
samples : list
list of numpy arrays containing the Monte Carlo samples
names : list
list of strings labeling the indivdual samples
idl : list, optional
list of ranges or lists on which the samples are defined
means : list, optional
list of mean values for the case that the mean values were
already subtracted from the samples
"""
if means is None: if means is None:
if len(samples) != len(names): if len(samples) != len(names):
@ -173,17 +192,22 @@ class Obs:
Keyword arguments Keyword arguments
----------------- -----------------
S -- specifies a custom value for the parameter S (default 2.0), can be S : float
a float or an array of floats for different ensembles specifies a custom value for the parameter S (default 2.0), can be
tau_exp -- positive value triggers the critical slowing down analysis a float or an array of floats for different ensembles
(default 0.0), can be a float or an array of floats for tau_exp : float
different ensembles positive value triggers the critical slowing down analysis
N_sigma -- number of standard deviations from zero until the tail is (default 0.0), can be a float or an array of floats for different
attached to the autocorrelation function (default 1) ensembles
e_tag -- number of characters which label the ensemble. The remaining N_sigma : float
ones label replica (default 0) number of standard deviations from zero until the tail is
fft -- boolean, which determines whether the fft algorithm is used for attached to the autocorrelation function (default 1)
the computation of the autocorrelation function (default True) e_tag : int
number of characters which label the ensemble. The remaining
ones label replica (default 0)
fft : bool
determines whether the fft algorithm is used for the computation
of the autocorrelation function (default True)
""" """
if 'e_tag' in kwargs: if 'e_tag' in kwargs:
@ -846,11 +870,15 @@ def expand_deltas_for_merge(deltas, idx, shape, new_idx):
Parameters Parameters
---------- ----------
deltas -- List of fluctuations deltas : list
idx -- List or range of configs on which the deltas are defined. List of fluctuations
Has to be a subset of new_idx. idx : list
shape -- Number of configs in idx. List or range of configs on which the deltas are defined.
new_idx -- List of configs that defines the new range. Has to be a subset of new_idx.
shape : list
Number of configs in idx.
new_idx : list
List of configs that defines the new range.
""" """
if type(idx) is range and type(new_idx) is range: if type(idx) is range and type(new_idx) is range:
@ -903,20 +931,24 @@ def derived_observable(func, data, **kwargs):
Parameters Parameters
---------- ----------
func -- arbitrary function of the form func(data, **kwargs). For the func : object
automatic differentiation to work, all numpy functions have to have arbitrary function of the form func(data, **kwargs). For the
the autograd wrapper (use 'import autograd.numpy as anp'). automatic differentiation to work, all numpy functions have to have
data -- list of Obs, e.g. [obs1, obs2, obs3]. the autograd wrapper (use 'import autograd.numpy as anp').
data : list
list of Obs, e.g. [obs1, obs2, obs3].
Keyword arguments Keyword arguments
----------------- -----------------
num_grad -- if True, numerical derivatives are used instead of autograd num_grad : bool
(default False). To control the numerical differentiation the if True, numerical derivatives are used instead of autograd
kwargs of numdifftools.step_generators.MaxStepGenerator (default False). To control the numerical differentiation the
can be used. kwargs of numdifftools.step_generators.MaxStepGenerator
man_grad -- manually supply a list or an array which contains the jacobian can be used.
of func. Use cautiously, supplying the wrong derivative will man_grad : list
not be intercepted. manually supply a list or an array which contains the jacobian
of func. Use cautiously, supplying the wrong derivative will
not be intercepted.
Notes Notes
----- -----
@ -1077,9 +1109,11 @@ def reweight(weight, obs, **kwargs):
Parameters Parameters
---------- ----------
weight -- Reweighting factor. An Observable that has to be defined on a superset of the weight : Obs
configurations in obs[i].idl for all i. Reweighting factor. An Observable that has to be defined on a superset of the
obs -- list of Obs, e.g. [obs1, obs2, obs3]. configurations in obs[i].idl for all i.
obs : list
list of Obs, e.g. [obs1, obs2, obs3].
Keyword arguments Keyword arguments
----------------- -----------------