chemprop.utils
==============

.. py:module:: chemprop.utils


Submodules
----------

.. toctree::
   :maxdepth: 1

   /autoapi/chemprop/utils/registry/index
   /autoapi/chemprop/utils/utils/index
   /autoapi/chemprop/utils/v1_to_v2/index
   /autoapi/chemprop/utils/v2_0_to_v2_1/index


Classes
-------

.. autoapisummary::

   chemprop.utils.ClassRegistry
   chemprop.utils.Factory
   chemprop.utils.EnumMapping


Functions
---------

.. autoapisummary::

   chemprop.utils.create_and_call_object
   chemprop.utils.make_mol
   chemprop.utils.parallel_execute
   chemprop.utils.pretty_shape


Package Contents
----------------

.. py:class:: ClassRegistry

   Bases: :py:obj:`dict`\ [\ :py:obj:`str`\ , :py:obj:`Type`\ [\ :py:obj:`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)


   .. py:method:: register(alias = None)


   .. py:attribute:: __call__


   .. py:method:: __repr__()

      Return repr(self).



   .. py:method:: __str__()

      Return str(self).



.. py:class:: Factory

   .. py:method:: build(clz_T, *args, **kwargs)
      :classmethod:



.. py:class:: EnumMapping

   Bases: :py:obj:`enum.StrEnum`


   Enum where members are also (and must be) strings


   .. py:method:: get(name)
      :classmethod:



   .. py:method:: keys()
      :classmethod:



   .. py:method:: values()
      :classmethod:



   .. py:method:: items()
      :classmethod:



.. py:function:: create_and_call_object(cls, call_args = (), call_kwargs = None, init_args = (), init_kwargs = None)

   Instantiate a class with optional init args, then call the instance with args.
   This is useful for parallel calls to methods that contain boost functions.


.. py:function:: make_mol(smi, keep_h = False, add_h = False, ignore_stereo = False, reorder_atoms = False)

   build an RDKit molecule from a SMILES string.

   :param smi: a SMILES string.
   :type smi: str
   :param keep_h: whether to keep hydrogens in the input smiles. This does not add hydrogens, it only keeps
                  them if they are specified. Default is False.
   :type keep_h: bool, optional
   :param add_h: whether to add hydrogens to the molecule. Default is False.
   :type add_h: bool, optional
   :param ignore_stereo: whether to ignore stereochemical information (R/S and Cis/Trans) when constructing the molecule. Default is False.
   :type ignore_stereo: bool, optional
   :param reorder_atoms: whether to reorder the atoms in the molecule by their atom map numbers. This is useful when
                         the order of atoms in the SMILES string does not match the atom mapping, e.g. '[F:2][Cl:1]'.
                         Default is False. NOTE: This does not reorder the bonds.
   :type reorder_atoms: bool, optional

   :returns: the RDKit molecule.
   :rtype: Chem.Mol


.. py:function:: parallel_execute(exe_func, func_args = (), func_kwargs = (), n_workers = 0)

   Optionally executes a function in parallel.

   :param exe_func: function to execute.
   :type exe_func: Callable
   :param func_args: arguments for each iteration of function execution.
   :type func_args: Iterable
   :param func_kwargs: keyword arguments for each iteration of function execution.
   :type func_kwargs: Iterable
   :param n_workers: Number of parallel workers.
   :type n_workers: int, optional

   :returns: list of function outputs for each argument.
   :rtype: list


.. py:function:: pretty_shape(shape)

   Make a pretty string from an input shape

   .. rubric:: Example

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


