Skip to content

declearn.utils.access_types_mapping

Return a copy of the {name: type} mapping of a given group.

Parameters:

Name Type Description Default
group str

Name of a TypesRegistry, the mapping from which to return.

required

Returns:

Name Type Description
mapping Dict[str, type]

{name: type} dict mapping of registered types. Note that this is a copy of the actual registry.

Raises:

Type Description
KeyError

If the group types registry does not exist.

Source code in declearn/utils/_register.py
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
def access_types_mapping(
    group: str,
) -> Dict[str, Type]:
    """Return a copy of the `{name: type}` mapping of a given group.

    Parameters
    ----------
    group: str
        Name of a TypesRegistry, the mapping from which to return.

    Returns
    -------
    mapping: Dict[str, type]
        `{name: type}` dict mapping of registered types.
        Note that this is a copy of the actual registry.

    Raises
    ------
    KeyError
        If the `group` types registry does not exist.
    """
    if group not in REGISTRIES:
        raise KeyError(f"Type registry '{group}' does not exist.")
    return REGISTRIES[group].get_mapping()