lightcurvelynx.math_nodes.state_expansion_node
The StateExpansionNode is a special FunctionNode that expands the graph state to flatten out subparameters – where a single row is transformed into multiple related rows. This node is meant to be used in the rare case that a single step in the parameter sampling process needs to change the number of samples (one sample branching into multiple results).
Note
This class is experimental and may be removed in the future.
Classes
A special FunctionNode that expands the graph state to flatten out the subparameters |
Module Contents
- class StateExpansionNode(*, param_names=None, param_values=None, repeats=None, **kwargs)[source]
Bases:
lightcurvelynx.base_models.FunctionNodeA special FunctionNode that expands the graph state to flatten out the subparameters that indicate multiple different behaviors per-row. For example, strong lensing will split a single object into multiple light curves (with different magnifications and time delays). The user provides a list of subparameter dictionaries where each dictionary lists the values for the new columns to be added for each sample. Alternatively, the user can directly provide the number of repeats for each sample to produce identical copies of the rows without adding any new columns.
Because of the structure of sampling, each ExpansionNode will only be triggered once during each sampling process.
Note
This class is experimental and may be removed in the future.
- Parameters:
param_names (list of str, optional) – A list of parameters to unpack from the param_values argument. Default: None
param_values (parameter) – A list of dictionaries where each dictionary contains the same keys (new column names) and the values for each parameter. The number of dictionaries must be the same as the number of samples in the graph state. Default: None
repeats (int or list of int, optional) – The number of repeats for each sample. If an int is provided, it is applied to all samples. If a list is provided, it must be the same length as the number of samples in the graph state and specifies the number of repeats for each sample. Only used if param_values is not provided. Default: None
**kwargs (dict, optional) – Additional keyword arguments.
- compute(graph_state, rng_info=None, **kwargs)[source]
Expand the graph state by applying the repeat() method.
- Parameters:
graph_state (GraphState) – An object mapping graph parameters to their values. This object is modified in place as it is sampled.
rng_info (numpy.random._generator.Generator, optional) – A given numpy random number generator to use for this computation. If not provided, the function uses the node’s random number generator.
**kwargs (dict, optional) – Additional function arguments.
- Returns:
A list containing the original indices and sub-indices for each sample after expansion, as well as any new parameter values if provided. The order of the returned list is: [org_inds, sub_inds, new_param_1_values, new_param_2_values, …] where the new parameter values match the order of the param_names provided during initialization.
- Return type:
list