Factorial Utilities
cuthbert.factorial.utils
Utility functions to convert between serial and factorial trees.
serial_to_factorial(extract, serial_tree, serial_factorial_inds, select_factorial_inds=None, init_factorial_tree=None)
Convert a serial tree into one or more single-factor trees.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extract
|
Extract
|
Function to extract the relevant factors from the serial tree. |
required |
serial_tree
|
ArrayTreeLike
|
The serial tree to convert.
Each leaf of the tree should have shape (T, F, ...) where T is the number of
time steps and F is the number of factors.
Although some leaves may not have the factorial dimension F, as controlled
by the |
required |
serial_factorial_inds
|
ArrayLike
|
The indices of the factors used in each element of the serial tree. Shape (T, F). |
required |
select_factorial_inds
|
int | ArrayLike | None
|
Single integer index or array of indices of the factors to extract in the output. If None, extract all factors from zero through the maximum index, preserving the behaviour of earlier versions. |
None
|
init_factorial_tree
|
ArrayTree
|
Optional initial factorial tree to use, as the first element of each returned tree. Leaves with shape (F, ...). Subtrees that are None in the initial tree (such as model_inputs) are padded with dummy values matching the history. |
None
|
Returns:
| Type | Description |
|---|---|
ArrayTree | list[ArrayTree]
|
A single tree when a single index is selected; otherwise, a list of trees in the |
ArrayTree | list[ArrayTree]
|
order of |
ArrayTree | list[ArrayTree]
|
|
ArrayTree | list[ArrayTree]
|
tree is supplied). |