CADETProcess.parameter_space.parse_path

Contents

CADETProcess.parameter_space.parse_path#

CADETProcess.parameter_space.parse_path(path: str) tuple[str | int | slice, ...][source]#

Split a path string into typed segments.

Dot notation separates attribute / dict-key hops. Bracket notation at the end of a segment specifies an array index or slice.

Parameters:
pathstr

Path string, e.g. "column.length", "film_diffusion[2]", "column.film_diffusion[1:3]", or "units[0].column.length".

Returns:
tuple[str | int | slice, …]

Non-empty tuple of segments. String segments are attribute names or dict keys; int and slice segments are array indices.

Raises:
ValueError

If path is empty, contains an empty attribute segment, or has malformed bracket notation.

Examples

>>> parse_path("column.length")
('column', 'length')
>>> parse_path("film_diffusion[2]")
('film_diffusion', 2)
>>> parse_path("column.film_diffusion[1:3]")
('column', 'film_diffusion', slice(1, 3, None))
>>> parse_path("units[0].column.length")
('units', 0, 'column', 'length')
>>> parse_path("feed")
('feed',)