ParameterSubspace

Instances of ParameterSubspace represent subspaces of the global parameter space associated with a model.

class xpsi.ParameterSubspace.ParameterSubspace(*args, **kwargs)[source]

Ordered parameter subspace.

Parameters:
  • prefix (str) – In common modelling patterns there are multiple instances of a particular subspace, so provide a unique naming prefix. The prefix will be suffixed with a double-underscore. Note that this prefix will prepend prefixes for encapsulated parameters lower in the hierarchy which themselves have identification prefixes.

  • args – Instances of Parameter, or iterables over instances of Parameter or ParameterSubspace. All parameters and subspaces will be merged into this new subspace.

__call__(p=None)[source]

Useful callable way to update parameters with a simple vector.

The order must match the order in which parameters were merged into the subspace. Note that this method is often overwritten in subclasses, but this parent method can always be accessed if required.

Parameters:

p (array-like) – New point to update to. If None, the current point is returned. The object must be ordered to match that of container self.

Returns:

Current point (if the call was not an update).

Return type:

array-like

__getitem__(key)[source]

Pass a string or an integer (latter only for free parameters).

__iter__()[source]

Get an iterator over free parameters.

__next__()[source]

Get next free parameter.

__repr__()[source]

Redirect to the string representation.

__setitem__(key, value)[source]

Pass a string or an integer (latter only for free parameters).

__str__()[source]

Get a summary of the parameters constituting the subspace.

classmethod _update_doc()[source]

Append the docstring with parameter names in class attributes.

property cached

Get the cached values of all free parameters in the subspace.

clear_cache()[source]

Clear the cache for all free parameters in the subspace.

Note

That this also deletes the current parameter values, in addition to the cached previous values.

get_param(name)[source]

Get a reference to a parameter object by name.

index(name)[source]

Get the index of a free parameter.

merge(*args)[source]

Merge parameters into the subspace, thereby expanding it.

property names

Get a list of parameter names.

property needs_update

Do cached dependencies need to be updated?

property params

Get the list of parameter objects.

property prefix

Get the unique prefix for subspace identification.

property vector

Get all variable values (free parameters and fixed/derived).