imas_validator.rules.helpers.Parent

imas_validator.rules.helpers.Parent(wrapped: IDSWrapper, level: int = 1) IDSWrapper

Get the parent of an IDS node.

Will raise an exception when attempting to get the parent of an IDS toplevel node.

Example

>>> node = core_profiles.profiles_1d[0].ion[1].label
>>> Parent(node)
IDSWrapper(<IDSStructure (IDS:core_profiles, profiles_1d[0]/ion[1])>)
>>> Parent(node, 2)
IDSWrapper(<IDSStructArray (IDS:core_profiles, profiles_1d[0]/ion with 2 items)>)
>>> Parent(node, 3)
IDSWrapper(<IDSStructure (IDS:core_profiles, profiles_1d[0])>)
>>> Parent(node, 4)
IDSWrapper(<IDSStructArray (IDS:core_profiles, profiles_1d with 1 items)>)
>>> Parent(node, 5)
IDSWrapper(<IDSToplevel (IDS:core_profiles)>)
>>> Parent(node, 6)
[...]
ValueError: Cannot get the parent of <IDSToplevel (IDS:core_profiles)>
Parameters:
wrapped: IDSWrapper

IDS node

level: int = 1

Specify which "level" parent you want. For example, level=2 returns the grandparent of the given IDS node.


Last update: 2025-08-29