lib.samples.plotting.SamplesPlotStyle¶
- class lib.samples.plotting.SamplesPlotStyle(style=None, **kwargs)¶
Bases:
lib.samples.plotting.ParameterPlotStylePlotting style for samples. It holds default attributes (
truths,colors, etc.) that can be set at initialization (style = SamplesPlotStyle(colors='r')) or at any time usingupdate().Initialize
SamplesPlotStyle.- Parameters
style (SamplesPlotStyle, default=None) – A plotting style to start from, which will be updated with
kwargs.kwargs (dict) – Attributes for
SamplesPlotStyle.
Methods
Return shallow copy of
self.deepcopyInstantiate and initalize class with state dictionary.
Return
valueif notNone, else attributenameif notNone, elsedefault.Return color corresponding to label
label.If parameters is
None, return varied parameters fromsamples.Return default truth / reference values for parameters.
Same as
get(), but ensuring returned value is a list.Return parameters.
is_mpi_broadcastis_mpi_gatheredis_mpi_rootis_mpi_scatteredLoad class in numpy binary format from disk.
If different formats are possible, this method should between them based on file name extension.
log_criticallog_debuglog_errorlog_infolog_warningPlot 1D distribution of samples.
Plot 2D distribution of samples.
Plot integrated autocorrelation time.
Make trace plot.
Make corner plot.
Plot Gelman-Rubin statistics.
Save class to disk.
If different formats are possible, this method should between them based on file name extension.
Save figure to
filename.Update attibutes with those in
kwargs.Attributes
loggerMPI attributes
mpicommmpirootmpistate- copy()¶
Return shallow copy of
self.
- classmethod from_state(state, mpiroot=0, mpicomm=None)¶
Instantiate and initalize class with state dictionary.
- get(name, value=None, default=None)¶
Return
valueif notNone, else attributenameif notNone, elsedefault.- Parameters
name (string) – Attribute name. If
None, defaults todefault.value (object, default=None) – Value. If
None, returns attributename.default (object, default=None) – Default value.
- get_color(label, labels=None)¶
Return color corresponding to label
label. Ifcolorsis a list, return color at index oflabelin list of labelslabels.
- static get_default_parameters(parameters, samples)¶
If parameters is
None, return varied parameters fromsamples.
- get_default_truths(parameters, truths=None)¶
Return default truth / reference values for parameters.
- Parameters
parameters (Parameter, tuple, list, ParameterCollection) – Parameters to return truth values for.
truths (list, default=None) – List of truth values. If
None, returntruthsif exists, else set all truths toNone. If'value', return list ofParameter.value.
- Returns
truths – Return single value if
parametersis a single parameter.- Return type
float, list
- get_list(name, value=None, default=None)¶
Same as
get(), but ensuring returned value is a list. Default length (seemake_list()) is taken asdefaultlength.
- static get_parameters(parameters, chains=None)¶
Return parameters.
- Parameters
parameters (tuple, list, ParameterCollection) – List of parameter (names). If parameter name, get the xorresponding parameter in the first element in
chainsthat contains this parameter.chains (list) – List of classes with
parametersattribute.
- Returns
toret – Return single parameter if
parametersis a single parameter (name).- Return type
- classmethod load(filename, mpiroot=0, mpicomm=None)¶
Load class in numpy binary format from disk. If the loaded state contains
__class__and that exists incls._registry, return instance ofcls._registry[__class__](instead ofcls).
- load_auto(*args, **kwargs)¶
If different formats are possible, this method should between them based on file name extension.
- property mpiattrs¶
MPI attributes
- plot_1d(chains=None, parameter=None, labels=None, truth=None, ax=None, filename=None)¶
Plot 1D distribution of samples.
- Parameters
chains (list, default=None) – List of
Samplesinstances. Defaults tochains.parameter (Parameter, ParamName, string, tuple) – Parameter name.
labels (list, string) – Label(s) for input chains.
truth (float, string, default=None) – Plot this truth / reference value for parameter. If
'value', takeParameter.value.ax (matplotlib.axes.Axes, default=None) – Axes where to plot samples. If
None, takes current axes.filename (string, default=None) – If not
None, file name where to save figure.
- Returns
ax
- Return type
matplotlib.axes.Axes
- plot_2d(chains=None, parameters=None, labels=None, truths=None, ax=None, filename=None)¶
Plot 2D distribution of samples.
- Parameters
chains (list, default=None) – List of
Samplesinstances. Defaults tochains.parameters (tuple, list, ParameterCollection) – The two parameter name(s).
labels (list, string) – Label(s) for input chains.
truths (list, default=None) – Plot this truths / reference values for parameters. See
get_default_truths().ax (matplotlib.axes.Axes, default=None) – Axes where to plot samples. If
None, takes current axes.filename (string, default=None) – If not
None, file name where to save figure.
- Returns
ax
- Return type
matplotlib.axes.Axes
- plot_autocorrelation_time(chains=None, parameters=None, threshold=50, slices=None, ax=None, filename=None)¶
Plot integrated autocorrelation time.
- Parameters
chains (list, default=None) – List of
Samplesinstances. Defaults tochains.parameters (list, ParameterCollection) – The parameter names.
threshold (float, default=50) – If not
None, plot \(y = x/\mathrm{threshold}\) line. Integrated autocorrelation time estimation can be considered reliable when falling under this line.slices (list, array) – List of increasing number of steps to include in calculation of autocorrelation time.
ax (matplotlib.axes.Axes, default=None) – Axes where to plot samples. If
None, takes current axes.filename (string, default=None) – If not
None, file name where to save figure.
- Returns
ax
- Return type
matplotlib.axes.Axes
- plot_chain(chain, parameters=None, filename=None)¶
Make trace plot.
- Parameters
chain (Samples) – Samples to plot.
parameters (list, ParameterCollection) – The parameter names.
filename (string, default=None) – If not
None, file name where to save figure.
- Returns
fig (matplotlib.figure.Figure) – Figure.
lax (array) – Array of axes.
- plot_corner(chains=None, parameters=None, labels=None, truths=None, filename=None)¶
Make corner plot.
- Parameters
chains (list, default=None) – List of
Samplesinstances. Defaults tochains.parameters (list, ParameterCollection) – The parameter names.
labels (list, string) – Label(s) for input chains.
truths (list, default=None) – Plot this truths / reference values for parameters. See
get_default_truths().filename (string, default=None) – If not
None, file name where to save figure.
- Returns
fig (matplotlib.figure.Figure) – Figure.
dax (dict) – Dictionary of
ParamNameand tomatplotlib.axes.Axes: name: axes for 1D plots and (name1, name2): axes for 2D plots.
- plot_gelman_rubin(chains=None, parameters=None, multivariate=False, threshold=1.1, slices=None, ax=None, filename=None)¶
Plot Gelman-Rubin statistics.
- Parameters
chains (list, default=None) – List of
Samplesinstances. Defaults tochains.parameters (list, ParameterCollection) – The parameter names.
multivariate (bool, default=False) – If
True, add line for maximum of eigen value of Gelman-Rubin matrix. SeeSamples.gelman_rubin().threshold (float, default=1.1) – If not
None, plot horizontal line at this value.slices (list, array) – List of increasing number of steps to include in calculation of Gelman-Rubin statistics.
ax (matplotlib.axes.Axes, default=None) – Axes where to plot samples. If
None, takes current axes.filename (string, default=None) – If not
None, file name where to save figure.
- Returns
ax
- Return type
matplotlib.axes.Axes
- save(filename)¶
Save class to disk.
- save_auto(*args, **kwargs)¶
If different formats are possible, this method should between them based on file name extension.
- savefig(filename, fig=None)¶
Save figure to
filename.- Parameters
filename (string) – Path where to save figure.
fig (matplotlib.figure.Figure, default=None) – Figure to save. Defaults to current figure.
- update(**kwargs)¶
Update attibutes with those in
kwargs.