saealib.register#
- saealib.register(name=None)[source]#
Register a class or function under
name(defaultcls.__name__).Use this to make a custom
Algorithm/Surrogate/etc. subclass resolvable by name from a preset YAML file, the same way bundled components are:>>> from saealib import register >>> from saealib.surrogate.base import Surrogate >>> >>> @register() ... class MyCustomSurrogate(Surrogate): ... ...
MyCustomSurrogatecan now be referenced as"MyCustomSurrogate"or{"type": "MyCustomSurrogate", "params": {...}}anywhere a spec is accepted, e.g. in a preset consumed byset_preset().- Parameters:
name (str | None)
- Return type:
Callable[[T], T]