deepmd.utils.env_mat_stat
=========================

.. py:module:: deepmd.utils.env_mat_stat


Attributes
----------

.. autoapisummary::

   deepmd.utils.env_mat_stat.log


Classes
-------

.. autoapisummary::

   deepmd.utils.env_mat_stat.StatItem
   deepmd.utils.env_mat_stat.EnvMatStat


Module Contents
---------------

.. py:data:: log

.. py:class:: StatItem(number: float = 0, sum: float = 0, squared_sum: float = 0)

   
   A class to store the statistics of the environment matrix.


   :Parameters:

       **number** : :class:`python:float`
           The total size of given array.

       **sum** : :class:`python:float`
           The sum value of the matrix.

       **squared_sum** : :class:`python:float`
           The sum squared value of the matrix.














   ..
       !! processed by numpydoc !!

   .. py:attribute:: number
      :value: 0



   .. py:attribute:: sum
      :value: 0



   .. py:attribute:: squared_sum
      :value: 0



   .. py:method:: __add__(other: StatItem) -> StatItem


   .. py:method:: __mul__(scalar: float) -> StatItem


   .. py:method:: compute_avg(default: float = 0) -> float

      
      Compute the average of the environment matrix.


      :Parameters:

          **default** : :class:`python:float`, :obj:`optional`
              The default value of the average, by default 0.



      :Returns:

          :class:`python:float`
              The average of the environment matrix.











      ..
          !! processed by numpydoc !!


   .. py:method:: compute_std(default: float = 0.1, protection: float = 0.01) -> float

      
      Compute the standard deviation of the environment matrix.


      :Parameters:

          **default** : :class:`python:float`, :obj:`optional`
              The default value of the standard deviation, by default 1e-1.

          **protection** : :class:`python:float`, :obj:`optional`
              The protection value for the standard deviation, by default 1e-2.



      :Returns:

          :class:`python:float`
              The standard deviation of the environment matrix.











      ..
          !! processed by numpydoc !!


.. py:class:: EnvMatStat

   Bases: :py:obj:`abc.ABC`


   
   A base class to store and calculate the statistics of the environment matrix.
















   ..
       !! processed by numpydoc !!

   .. py:attribute:: stats


   .. py:method:: compute_stats(data: list[dict[str, numpy.ndarray]]) -> None

      
      Compute the statistics of the environment matrix.


      :Parameters:

          **data** : :class:`python:list`\[:class:`python:dict`\[:class:`python:str`, :obj:`np.ndarray <numpy.ndarray>`]]
              The environment matrix.














      ..
          !! processed by numpydoc !!


   .. py:method:: iter(data: list[dict[str, numpy.ndarray]]) -> collections.abc.Iterator[dict[str, StatItem]]
      :abstractmethod:


      
      Get the iterator of the environment matrix.


      :Parameters:

          **data** : :class:`python:list`\[:class:`python:dict`\[:class:`python:str`, :obj:`np.ndarray <numpy.ndarray>`]]
              The environment matrix.




      :Yields:

          :class:`python:dict`\[:class:`python:str`, :obj:`StatItem`]
              The statistics of the environment matrix.










      ..
          !! processed by numpydoc !!


   .. py:method:: save_stats(path: deepmd.utils.path.DPPath) -> None

      
      Save the statistics of the environment matrix.


      :Parameters:

          **path** : :obj:`DPPath`
              The path to save the statistics of the environment matrix.














      ..
          !! processed by numpydoc !!


   .. py:method:: load_stats(path: deepmd.utils.path.DPPath) -> None

      
      Load the statistics of the environment matrix.


      :Parameters:

          **path** : :obj:`DPPath`
              The path to load the statistics of the environment matrix.














      ..
          !! processed by numpydoc !!


   .. py:method:: load_or_compute_stats(data: list[dict[str, numpy.ndarray]], path: deepmd.utils.path.DPPath | None = None) -> None

      
      Load the statistics of the environment matrix if it exists, otherwise compute and save it.


      :Parameters:

          **path** : :obj:`DPPath`
              The path to load the statistics of the environment matrix.

          **data** : :class:`python:list`\[:class:`python:dict`\[:class:`python:str`, :obj:`np.ndarray <numpy.ndarray>`]]
              The environment matrix.














      ..
          !! processed by numpydoc !!


   .. py:method:: get_avg(default: float = 0) -> dict[str, float]

      
      Get the average of the environment matrix.


      :Parameters:

          **default** : :class:`python:float`, :obj:`optional`
              The default value of the average, by default 0.



      :Returns:

          :class:`python:dict`\[:class:`python:str`, :class:`python:float`]
              The average of the environment matrix.











      ..
          !! processed by numpydoc !!


   .. py:method:: get_std(default: float = 0.1, protection: float = 0.01) -> dict[str, float]

      
      Get the standard deviation of the environment matrix.


      :Parameters:

          **default** : :class:`python:float`, :obj:`optional`
              The default value of the standard deviation, by default 1e-1.

          **protection** : :class:`python:float`, :obj:`optional`
              The protection value for the standard deviation, by default 1e-2.



      :Returns:

          :class:`python:dict`\[:class:`python:str`, :class:`python:float`]
              The standard deviation of the environment matrix.











      ..
          !! processed by numpydoc !!


