pysdic.Parametrization.encode#
- Parametrization.encode(p_i, *, dp=False, **kwargs)[source]#
Apply the parametrization to the given parameters \(\vec{p_i} \in \mathbb{R}^{n_i}\) to return the encoded parameters \(\vec{p_o} \in \mathbb{R}^{n_o}\).
\[\vec{p_o} = P(\vec{p_i})\]Important
The encode method can only be used if the parametrization implements it (i.e.,
has_encodemust be True).The jacobian
dpcan only be computed if the parametrization supports it (i.e.,has_encode_dpmust be True).
Note
This method is called by
__call__to allow the parametrization to be applied directly to parameters using the syntaxparametrization(p_i).- Parameters:
p_i (ArrayLike) – Input parameters \(\vec{p_i}\) with shape \((n_i,)\) to which the parametrization will be applied.
dp (bool, optional (default:
False)) – Whether to compute the Jacobian with respect to the input parameters. (i.e., \(\mathbf{J}_p = \frac{\partial P}{\partial \vec{p_i}}\)).**kwargs – Additional arguments passed to the underlying
_encodemethod.
- Returns:
Contains the encoded parameters accessible using the
pattribute with shape \((n_o,)\), and the Jacobian matrix with respect to the input parameters accessible using thejacobian_dpattribute with shape \((n_o, n_i)\) if computed, or None otherwise.- Return type:
Notes
The jacobian
dphas the following structure:jacobian_dp[0, 0] # ∂p_o1/∂p_i1 jacobian_dp[0, 1] # ∂p_o1/∂p_i2 jacobian_dp[1, 0] # ∂p_o2/∂p_i1 jacobian_dp[1, 1] # ∂p_o2/∂p_i2 jacobian_dp[j, i] # ∂p_oj/∂p_ii
Developers notes#
Subclasses must implement the
_encodemethod. This method should:Accept a NumPy array of shape \((n_i,)\).
Return \(\vec{p_o}\) Numpy array of shape \((n_o,)\) and optionally the Jacobian matrix with respect to the input parameters as a 2D array of shape \((n_o, n_i)\) if
dpis True, or None otherwise.
The shapes of the outputs of
_encodeare checked, and aRuntimeErroris raised if they do not match the expected shapes.