pysdic.ComposedParametrization#
The pysdic.ComposedParametrization provides a standardized way to manage composed parametrizations,
allowing for the combination of multiple parametrizations \([P_1, P_2, \dots, P_n]\) into a single
parametrization \(P = P_n \circ \dots \circ P_1\).
The syntax P2 @ P1 is equivalent to ComposedParametrization([P1, P2]).
ComposedParametrization class#
- class ComposedParametrization(parametrizations)[source]#
Bases:
ParametrizationA composition of multiple
pysdic.Parametrizationinstances.This class allows you to compose multiple parametrizations together, where the output of one parametrization is fed as the input to the next. The resulting composition behaves like a single parametrization that encodes parameters through the sequence of parametrizations.
For example, if you have two parametrizations \(P_1\) and \(P_2\), you can create a composition \(P = P_2 \circ P_1\) such that:
\[P(\vec{p}) = P_2(P_1(\vec{p}))\]where \(\vec{p}\) are the parameters to encode. The decoding map is applied in the reverse order:
\[P^{-1}(\vec{p}) = P_1^{-1}(P_2^{-1}(\vec{p}))\]See also
Class
pysdic.Parametrizationfor the base class of parametrizations.The syntax
P2 @ P1which is equivalent toComposedParametrization([P1, P2]).
Note
The number of parametrizations in the composition must be at least 1 and cannot be changed after initialization. In addition, the parametrizations stored in the composition cannot be changed after initialization.
Note
Locking the composition (by an owner of the package) also locks all its parametrizations, recursively for nested compositions.
Note
The capability flags of the composition are derived from the flags of the parametrizations: a flag is True only if it is True for all the parametrizations. For example, the composition is left invertible if all the parametrizations are left invertible, since:
\[P_1^{-1} \circ P_2^{-1} \circ P_2 \circ P_1 = P_1^{-1} \circ P_1 = \text{Id}\]- Parameters:
parametrizations (List[Parametrization]) – A list of parametrization instances to compose together. The output dimension of each parametrization must match the input dimension of the next. The order of the list is \([P_1, P_2, ..., P_n]\) where \(P_1\) is the first parametrization applied to the parameters.
Implemented methods and attributes#
The following sections provide an overview of the attributes and methods defined
in the pysdic.ComposedParametrization class.
Attributes#
The pysdic.ComposedParametrization defines or redefines the following attributes:
[Get] the input dimension \(n_i\) of the composition, i.e. the input dimension of the first parametrization \(P_1\). |
|
[Get] the number of parametrizations in the composition. |
|
[Get] the output dimension \(n_o\) of the composition, i.e. the output dimension of the last parametrization \(P_n\). |
|
[Get] the list of parametrizations that are composed together. |
Methods#
The pysdic.ComposedParametrization implements
the following backend methods to encode and decode the
composed parametrization:
|
Encode the parameters through the sequence of parametrizations. |
|
Decode the encoded parameters through the sequence of parametrizations in reverse. |
Note
The encode and decode methods of the composition accept the additional argument
kwargs: a list with one dictionary of keyword arguments per parametrization, in the order
\([P_1, \dots, P_n]\) (the same order for decode, even if the decoding is applied in reverse).