CodeEntropy.entropy.graph module

Entropy graph orchestration.

This module defines EntropyGraph, a small directed acyclic graph (DAG) that executes entropy calculation nodes in dependency order.

The graph is intentionally simple:
  • Vibrational entropy

  • Configurational entropy

  • Aggregation of results

The nodes themselves encapsulate the detailed calculations.

class CodeEntropy.entropy.graph.EntropyGraph[source]

Bases: object

Build and execute the entropy calculation DAG.

The graph is built once via build() and executed via execute().

Examples

graph = EntropyGraph().build() results = graph.execute(shared_data)

build() EntropyGraph[source]

Populate the graph with the standard entropy workflow.

Returns:

Self for fluent chaining.

execute(shared_data: dict[str, Any], *, progress: object | None = None) dict[str, Any][source]

Execute the entropy graph in topological order.

Nodes are executed in dependency order (topological sort). Each node reads from and may mutate shared_data. Dict-like outputs returned by nodes are merged into a single results dictionary.

This method intentionally does not create a progress bar/task for the entropy graph itself because the graph is typically very fast. If a progress sink is provided, it is forwarded to nodes that accept it.

Parameters:
  • shared_data – Mutable shared data dictionary passed to each node.

  • progress – Optional progress sink (e.g., from ResultsReporter.progress()). Forwarded to node run() methods that accept a progress keyword.

Returns:

Dictionary containing merged dict outputs produced by nodes. On key collision, later nodes overwrite earlier keys.

Raises:

KeyError – If a node name is missing from the internal node registry.

class CodeEntropy.entropy.graph.NodeSpec(name: str, node: Any, deps: tuple[str, ...] = ())[source]

Bases: object

Specification for a node within the entropy graph.

Variables:
  • name (str) – Unique node name.

  • node (Any) – Node instance. Must implement run(shared_data, **kwargs).

  • deps (tuple[str, ...]) – Optional list of node names that must run before this node.

deps: tuple[str, ...] = ()
name: str
node: Any