schrodinger.models.param_class_convertors module

Utility functions for converting between CompoundParam classes and other types.

class schrodinger.models.param_class_convertors.DCCompoundParamMeta(name, parents, dct, **kwargs)

Bases: schrodinger.models.parameters.CompoundParamMeta

class schrodinger.models.param_class_convertors.DCCompoundParam(*args, _param_type=<object object>, **kwargs)

Bases: schrodinger.models.parameters.CompoundParam

initializeValue()

Override to dynamically set up the default value of the param. Useful for default values that are determined at runtime. This is called any time the param is reset.

schrodinger.models.param_class_convertors.dataclass_to_compoundparam(DataClass: type, child_compound_params: list = None)

Converts a dataclass to a CompoundParam class. The new class will have the same attributes as the dataclass, with the same default values. Nested dataclasses are NOT converted to CompoundParam classes by default.

To get nested CompoundParams, first convert the child dataclasses to CompoundParams, then pass them in as the child_compound_params when converting the parent dataclass.

Example:

>>> @dataclasses.dataclass
... class Coord:
...     x: float
...     y: float
>>> @dataclasses.dataclass
... class Atom:
...     name: str
...     coord: Coord
>>> CoordCP = dataclass_to_compoundparam(Coord)
>>> AtomCP = dataclass_to_compoundparam(Atom, [CoordCP])

Note: also consider using paramable.paramable_dataclass instead of calling this function directly. Nested paramable_dataclass objects will be converted to CompoundParams automatically.