schrodinger.models.paramable module¶
- schrodinger.models.paramable.paramable_dataclass(*args, **kwargs)¶
Behaves just like the dataclasses.dataclass decorator, but also adds a getCompoundParamClass method to the class that returns a CompoundParam class that corresponds to the dataclass.
- Example:
>>> @paramable_dataclass ... class Coord: ... x: float = 1 ... y: float = 2
>>> CoordCP = Coord.getCompoundParamClass() >>> CoordCP.x.defaultValue() 1.0 >>> CoordCP.y.defaultValue() 2.0
Note: nested dataclasses will be left as dataclasses unless they are also decorated with paramable_dataclass.
paramable_dataclass accepts the same arguments as dataclasses.dataclass; they will not affect the CompoundParam class that is generated. (e.g. frozen=True will not make the CompoundParam class frozen)