Causality Base Class#
The causality module provides a base class for causality analysis.
- class macrostat.causality.CausalityAnalyzer(model_class: Type[Model])[source]
Bases:
object- analyze()[source]
Analyze a model class and return dependency dictionary
- check_for_cycles()[source]
Check for cycles in the model’s dependency graph.
While cycles are not necessarily a problem, cycling logic in a given step may indicate indeterminism. This method returns a list of cycles found in the created adjacency matrix.
- Returns:
List of cycles found in the graph. Each cycle is a list of nodes. Returns empty list if no cycles are found.
- Return type:
- plot_heatmap()[source]
Visualize the adjacency matrix organized by trophic levels.
- Parameters:
- Returns:
The figure object containing the plot
- Return type:
- plot_with_cytoscape(port: int = 8050, node_styles: dict[str, dict[str, str]] = {'history': {'background-color': 'lightgray', 'border-color': 'black'}, 'hyper': {'background-color': 'lavender', 'border-color': 'purple'}, 'parameters': {'background-color': 'lightgreen', 'border-color': 'green'}, 'prior': {'background-color': 'lightpink', 'border-color': 'red'}, 'scenario': {'background-color': 'lightyellow', 'border-color': 'yellow'}, 'state': {'background-color': 'lightblue', 'border-color': 'blue'}})[source]
Create an interactive flowchart visualization using Dash and Cytoscape.
This method creates a web-based interactive visualization of the model’s structure using Dash and Cytoscape. The visualization allows for: - Zooming and panning - Node selection and highlighting - Edge highlighting - Node dragging and repositioning - Export to various formats
- Parameters:
port (int, optional) – The port number to run the Dash server on, by default 8050
- Returns:
Opens a web browser with the interactive visualization
- Return type:
None