chemprop.utils#

Submodules#

Package Contents#

Classes#

ClassRegistry

dict() -> new empty dictionary

Factory

EnumMapping

Enum where members are also (and must be) strings

Functions#

make_mol(smi, keep_h, add_h)

build an RDKit molecule from a SMILES string.

pretty_shape(shape)

Make a pretty string from an input shape

class chemprop.utils.ClassRegistry[source]#

Bases: dict[str, Type[T]]

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

__call__#
register(alias=None)[source]#
Parameters:

alias (Any | Iterable[Any] | None)

__repr__()[source]#

Return repr(self).

Return type:

str

__str__()[source]#

Return str(self).

Return type:

str

class chemprop.utils.Factory[source]#
classmethod build(clz_T, *args, **kwargs)[source]#
Parameters:

clz_T (Type[T])

Return type:

T

class chemprop.utils.EnumMapping[source]#

Bases: enum.StrEnum

Enum where members are also (and must be) strings

classmethod get(name)[source]#
Parameters:

name (str | EnumMapping)

Return type:

EnumMapping

classmethod keys()[source]#
Return type:

Iterator[str]

classmethod values()[source]#
Return type:

Iterator[str]

classmethod items()[source]#
Return type:

Iterator[tuple[str, str]]

chemprop.utils.make_mol(smi, keep_h, add_h)[source]#

build an RDKit molecule from a SMILES string.

Parameters:
  • smi (str) – a SMILES string.

  • keep_h (bool) – whether to keep hydrogens in the input smiles. This does not add hydrogens, it only keeps them if they are specified

  • add_h (bool) – whether to add hydrogens to the molecule

Returns:

the RDKit molecule.

Return type:

Chem.Mol

chemprop.utils.pretty_shape(shape)[source]#

Make a pretty string from an input shape

Example

>>> X = np.random.rand(10, 4)
>>> X.shape
(10, 4)
>>> pretty_shape(X.shape)
'10 x 4'
Parameters:

shape (Iterable[int])

Return type:

str