r"""Base function for registering a module in GraphGym. Args: mapping (dict): Python dictionary to register the module. hosting all the registered modules key (string): The name of the module. module (any, optional): The module. If set to :obj:`None`, will re
(mapping: Dict[str, Any],
key: str,
module: Any = None)
| 21 | |
| 22 | |
| 23 | def register_base(mapping: Dict[str, Any], |
| 24 | key: str, |
| 25 | module: Any = None) -> Union[None, Callable]: |
| 26 | r"""Base function for registering a module in GraphGym. |
| 27 | |
| 28 | Args: |
| 29 | mapping (dict): Python dictionary to register the module. |
| 30 | hosting all the registered modules |
| 31 | key (string): The name of the module. |
| 32 | module (any, optional): The module. If set to :obj:`None`, will return |
| 33 | a decorator to register a module. |
| 34 | """ |
| 35 | if module is not None: |
| 36 | if key in mapping: |
| 37 | raise KeyError(f"Module with '{key}' already defined") |
| 38 | mapping[key] = module |
| 39 | return |
| 40 | |
| 41 | # Other-wise, use it as a decorator: |
| 42 | def bounded_register(module): |
| 43 | register_base(mapping, key, module) |
| 44 | return module |
| 45 | |
| 46 | return bounded_register |
| 47 | |
| 48 | |
| 49 | def register_act(key: str, module: Any = None): |
no outgoing calls
no test coverage detected