lightcurvelynx.math_nodes.modeldag_node

Wrapper class for sampling from the optional modeldag package, which provides tools for defining and sampling a directed acyclic graph (DAG) of parameters.

This code uses the modeldag package (https://github.com/MickaelRigault/modeldag), which is not installed by default. Users who want to use this functionality must install it separately, e.g. pip install modeldag.

Classes

ModelDAGNode

The base class for sampling from the modeldag package:

Module Contents

class ModelDAGNode(model, **kwargs)[source]

Bases: lightcurvelynx.base_models.FunctionNode, citation_compass.CiteClass

The base class for sampling from the modeldag package: https://github.com/MickaelRigault/modeldag

Note

The modeldag package is not installed by default. To use the modeldag functionality, users will need to install the modeldag package separately with pip install modeldag.

model[source]
Type:

modeldag.ModelDAG or dict

Parameters:

model (modeldag.ModelDAG or dict) – The modeldag object to sample from or a dictionary representing the modeldag. If a dictionary is provided, it will be converted to a modeldag.ModelDAG object.

References

https://github.com/MickaelRigault/modeldag

model[source]
compute(graph_state, rng_info=None, **kwargs)[source]

Sample from the wrapped prior.

The input arguments are taken from the current graph_state and the outputs are written to graph_state.

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 numpy random number generator to forward to modeldag.ModelDAG.draw. If not provided, modeldag will use its default randomness source.

  • **kwargs (dict, optional) – Additional function arguments.

Returns:

results – The result of the computation. This return value is provided so that testing functions can easily access the results.

Return type:

any

Raises:

ValueError – if func attribute is None.