saealib.register#

saealib.register(name=None)[source]#

Register a class or function under name (default cls.__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):
...     ...

MyCustomSurrogate can now be referenced as "MyCustomSurrogate" or {"type": "MyCustomSurrogate", "params": {...}} anywhere a spec is accepted, e.g. in a preset consumed by set_preset().

Parameters:

name (str | None)

Return type:

Callable[[T], T]