pySimBlocks.project.load_simulation_config

pySimBlocks.project.load_simulation_config.extract_external_refs(expr: str) set[str][source]

Extract all external reference names (#var syntax) from an expression string.

Hex color literals (e.g. #d62728 in plot series_styles) are ignored.

Parameters:

expr – A YAML value string potentially containing #name references.

Returns:

Set of referenced variable names with the # prefix stripped.

pySimBlocks.project.load_simulation_config.eval_value(value: Any, scope: dict) Any[source]

Evaluate a single YAML value as a Python expression.

The value is converted to string, # prefixes are stripped, bare list literals are wrapped in np.array(), and the result is evaluated using eval with a restricted namespace containing only np and scope. If evaluation fails the original value is returned unchanged.

Parameters:
  • value – Raw YAML value (string, number, list, etc.).

  • scope – Variable scope for expression evaluation (from the external parameters module).

Returns:

Evaluated Python object, or value unchanged if evaluation fails.

pySimBlocks.project.load_simulation_config.eval_recursive(obj: Any, scope: dict) Any[source]

Recursively evaluate all values in a nested dict/list using eval_value().

Parameters:
  • obj – A nested dict, list, or scalar YAML value.

  • scope – Variable scope for expression evaluation.

Returns:

The same structure with all leaf values passed through eval_value().

pySimBlocks.project.load_simulation_config.load_simulation_config(project_yaml: str | Path) Tuple[SimulationConfig, Dict[str, Any], Path][source]

Load simulation and diagram configuration from a unified project.yaml.

Parameters:

project_yaml – Path to the unified project.yaml file.

Returns:

A tuple (SimulationConfig, model_dict, params_dir) where params_dir is the directory of the project file.

Raises:
  • FileNotFoundError – If the project file does not exist.

  • ValueError – If the file is malformed or required fields are missing.