nessai.reparameterisations.utils#

Utilities for handling the reparameterisations.

Exceptions#

ReparameterisationError

Exception for reparameterisation errors

Classes#

KnownReparameterisation

Dataclass to store the reparameterisation class and keyword arguments

ReparameterisationSpec

Normalised representation of a reparameterisation config spec.

ReparameterisationDict

Dictionary of reparameterisations

Functions#

get_reparameterisation(reparameterisation[, defaults])

Function to get a reparameterisation class from a name

normalise_reparameterisation_spec(...)

Normalise a reparameterisation config entry into a list of spec configs.

build_reparameterisation_spec(key, spec_cfg, ...)

Build a normalised spec from a single config entry.

parse_reparameterisations(reparameterisations, model_names)

Parse user reparameterisation config into ordered specs.

resolve_reparameterisation_parameters(parameters, ...)

Resolve parameter names or regex patterns for reparameterisations.

Module Contents#

exception nessai.reparameterisations.utils.ReparameterisationError#

Bases: RuntimeError

Exception for reparameterisation errors

class nessai.reparameterisations.utils.KnownReparameterisation#

Dataclass to store the reparameterisation class and keyword arguments

class nessai.reparameterisations.utils.ReparameterisationSpec#

Normalised representation of a reparameterisation config spec.

class nessai.reparameterisations.utils.ReparameterisationDict#

Bases: dict

Dictionary of reparameterisations

This dictionary is used to store the known reparameterisations and provides a method to add new reparameterisations.

add_reparameterisation(name, class_fn, keyword_arguments=None)#

Add a new reparameterisation to the dictionary

Parameters:
namestr

Name of the reparameterisation.

class_fnReparameterisation

Reparameterisation class.

keyword_argumentsdict, optional

Keyword arguments for the reparameterisation.

nessai.reparameterisations.utils.get_reparameterisation(reparameterisation, defaults=None)#

Function to get a reparameterisation class from a name

Parameters:
reparameterisationstr, nessai.reparameterisations.Reparameterisation

Name of the reparameterisations to return or a class that inherits from Reparameterisation

defaultsdict, optional

Dictionary of known reparameterisations that overrides the defaults.

Returns:
nessai.reparameteristaions.Reparameterisation

Reparameterisation class.

dict

Keyword arguments for the specific reparameterisation.

nessai.reparameterisations.utils.normalise_reparameterisation_spec(key: str, cfg: str | dict | list | None, model_names: list[str]) list[dict] | list[str] | list[None]#

Normalise a reparameterisation config entry into a list of spec configs.

Parameters:
keystr

The key of the config entry.

cfgstr, dict, list, or None

The config entry to normalise.

model_nameslist of str

The names of the model parameters.

nessai.reparameterisations.utils.build_reparameterisation_spec(key, spec_cfg, spec_index, model_names)#

Build a normalised spec from a single config entry.

nessai.reparameterisations.utils.parse_reparameterisations(reparameterisations, model_names, class_name=None)#

Parse user reparameterisation config into ordered specs.

nessai.reparameterisations.utils.resolve_reparameterisation_parameters(parameters, available_parameters)#

Resolve parameter names or regex patterns for reparameterisations.