lib.samples.profiles.Profiles

class lib.samples.profiles.Profiles(parameters, attrs=None)

Bases: cosmopipe.lib.utils.BaseClass

Class holding results of likelihood profiling.

init

Initial parameter values.

Type

ParamDict

bestfit

Best fit parameters.

Type

ParamDict

parabolic_errors

Parameter parabolic errors.

Type

ParamDict

deltachi2_errors

Lower and upper errors corresponding to \(\Delta \chi^{2} = 1\).

Type

ParamDict

covariance

Parameter covariance at best fit.

Type

ParamCovariance

Initialize Profiles.

Parameters
  • parameters (list, ParameterCollection) – Parameters used in likelihood profiling.

  • attrs (dict, default=None) – Other attributes.

Methods

argmin

Return index of best best fit among all the tries.

concatenate

Concatenate profiles together.

copy

Return shallow copy of self.

deepcopy

extend

Extend profiles with other.

from_state

Instantiate and initalize class with state dictionary.

get

Access attribute by name.

has

Has this attribute?

is_mpi_broadcast

is_mpi_gathered

is_mpi_root

is_mpi_scattered

load

Load class in numpy binary format from disk.

load_auto

If different formats are possible, this method should between them based on file name extension.

log_critical

log_debug

log_error

log_info

log_warning

ntries

Return number of tries.

save

Save class to disk.

save_auto

If different formats are possible, this method should between them based on file name extension.

set_bestfit

Set best fit parameter values values.

set_covariance

Set parameter covariance covariance for parameters parameters.

set_deltachi2_errors

Set parameter \(\Delta \chi^{2} = 1\) errors values.

set_init

Set initial parameter values values.

set_metrics

Set metrics (e.g.

set_parabolic_errors

Set parameter parabolic errors values.

to_samples

Export profiles as Samples.

to_stats

Export profiling quantities.

Attributes

logger

mpiattrs

MPI attributes

mpicomm

mpiroot

mpistate

argmin()

Return index of best best fit among all the tries.

classmethod concatenate(*others)

Concatenate profiles together.

Parameters

others (list) – List of Profiles instances.

Returns

new

Return type

Profiles

Warning

attrs of returned profiles contains, for each key, the last value found in others attrs dictionaries.

copy()

Return shallow copy of self.

extend(other)

Extend profiles with other.

classmethod from_state(state, mpiroot=0, mpicomm=None)

Instantiate and initalize class with state dictionary.

get(name)

Access attribute by name.

has(name)

Has this attribute?

classmethod load(filename, mpiroot=0, mpicomm=None)

Load class in numpy binary format from disk. If the loaded state contains __class__ and that exists in cls._registry, return instance of cls._registry[__class__] (instead of cls).

load_auto(*args, **kwargs)

If different formats are possible, this method should between them based on file name extension.

property mpiattrs

MPI attributes

ntries()

Return number of tries.

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.

set_bestfit(values)

Set best fit parameter values values.

set_covariance(covariance, parameters=None)

Set parameter covariance covariance for parameters parameters.

set_deltachi2_errors(values)

Set parameter \(\Delta \chi^{2} = 1\) errors values.

set_init(values)

Set initial parameter values values.

set_metrics(values)

Set metrics (e.g. ‘loglkl’) dictionary values.

set_parabolic_errors(values)

Set parameter parabolic errors values.

classmethod to_samples(profiles, parameters=None, name='bestfit', select='min')

Export profiles as Samples. This is not statistically meaningful, but convenient to share plotting routines.

Parameters
  • profiles (list) – List of Profiles instances.

  • parameters (list, ParameterCollection, default=None) – Parameters to export. Defaults to all parameters.

  • name (string, default='bestfit') – Quantity to export as samples.

  • select (string, default='min') – Rule to select the quantity to export.

Returns

samples

Return type

Samples

to_stats(parameters=None, quantities=None, sigfigs=2, tablefmt='latex_raw', filename=None)

Export profiling quantities.

Parameters
  • parameters (list, ParameterCollection) – Parameters to export quantities for. Defaults to all parameters.

  • quantities (list, default=None) – Quantities to export. Defaults to ['bestfit','parabolic_errors','deltachi2_errors'].

  • sigfigs (int, default=2) – Number of significant digits. See utils.round_measurement().

  • tablefmt (string, default='latex_raw') – Format for summary table. See tabulate.tabulate().

  • filename (string default=None) – If not None, file name where to save summary table.

Returns

tab – Summary table.

Return type

string