Skip to content

Generic

generic

Helper functions to extract dependencies from generic lists and dictionaries.

Functions

extract_references

extract_references(expr: str) -> set[str]

Very simple parser to find all @references in a string expression.

Example: "@m1 * @q + 5" → ['m1', 'q']

Parameters:

Name Type Description Default
expr str

Expression.

required

Returns:

Type Description
set[str]

A set of variables names (without the @).

extract_dependencies_from_spec

extract_dependencies_from_spec(spec: dict[str, Any]) -> set[str]

Recursively find all @references in a parameter spec (handles nested dicts/lists).

Parameters:

Name Type Description Default
spec dict[str, Any]

A dictionary of specification.

required

Returns:

Type Description
set[str]

A set of @references.