deepmd.tf.utils.path
====================

.. py:module:: deepmd.tf.utils.path

.. autoapi-nested-parse::

   Alias for backward compatibility.

   ..
       !! processed by numpydoc !!


Classes
-------

.. autoapisummary::

   deepmd.tf.utils.path.DPH5Path
   deepmd.tf.utils.path.DPOSPath
   deepmd.tf.utils.path.DPPath


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

.. py:class:: DPH5Path(path: str, mode: str = 'r')

   Bases: :py:obj:`DPPath`


   
   The path class to data system (DeepmdData) for HDF5 files.


   :Parameters:

       **path** : :class:`python:str`
           path

       **mode** : :class:`python:str`, :obj:`optional`
           mode, by default "r"











   .. rubric:: Notes

   OS - HDF5 relationship:
       directory - Group
       file - Dataset



   ..
       !! processed by numpydoc !!

   .. py:attribute:: mode
      :value: 'r'



   .. py:attribute:: root_path


   .. py:attribute:: root


   .. py:attribute:: _name


   .. py:method:: _load_h5py(path: str, mode: str = 'r') -> h5py.File
      :classmethod:


      
      Load hdf5 file.


      :Parameters:

          **path** : :class:`python:str`
              path to hdf5 file

          **mode** : :class:`python:str`, :obj:`optional`
              mode, by default 'r'














      ..
          !! processed by numpydoc !!


   .. py:method:: load_numpy() -> numpy.ndarray

      
      Load NumPy array.





      :Returns:

          :obj:`np.ndarray <numpy.ndarray>`
              loaded NumPy array











      ..
          !! processed by numpydoc !!


   .. py:method:: load_txt(dtype: Optional[numpy.dtype] = None, **kwargs) -> numpy.ndarray

      
      Load NumPy array from text.





      :Returns:

          :obj:`np.ndarray <numpy.ndarray>`
              loaded NumPy array











      ..
          !! processed by numpydoc !!


   .. py:method:: save_numpy(arr: numpy.ndarray) -> None

      
      Save NumPy array.


      :Parameters:

          **arr** : :obj:`np.ndarray <numpy.ndarray>`
              NumPy array














      ..
          !! processed by numpydoc !!


   .. py:method:: glob(pattern: str) -> list[DPPath]

      
      Search path using the glob pattern.


      :Parameters:

          **pattern** : :class:`python:str`
              glob pattern



      :Returns:

          :class:`python:list`\[:obj:`DPPath`]
              list of paths











      ..
          !! processed by numpydoc !!


   .. py:method:: rglob(pattern: str) -> list[DPPath]

      
      This is like calling :meth:`DPPath.glob()` with `**/` added in front
      of the given relative pattern.


      :Parameters:

          **pattern** : :class:`python:str`
              glob pattern



      :Returns:

          :class:`python:list`\[:obj:`DPPath`]
              list of paths











      ..
          !! processed by numpydoc !!


   .. py:property:: _keys
      :type: list[str]


      
      Walk all groups and dataset.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: __file_new_keys
      :type:  ClassVar[dict[h5py.File, list[str]]]


   .. py:property:: _new_keys

      
      New keys that haven't been cached.
















      ..
          !! processed by numpydoc !!


   .. py:method:: _file_keys(file: h5py.File) -> list[str]
      :classmethod:


      
      Walk all groups and dataset.
















      ..
          !! processed by numpydoc !!


   .. py:method:: is_file() -> bool

      
      Check if self is file.
















      ..
          !! processed by numpydoc !!


   .. py:method:: is_dir() -> bool

      
      Check if self is directory.
















      ..
          !! processed by numpydoc !!


   .. py:method:: __truediv__(key: str) -> DPPath

      
      Used for / operator.
















      ..
          !! processed by numpydoc !!


   .. py:method:: _connect_path(path: str) -> str

      
      Connect self with path.
















      ..
          !! processed by numpydoc !!


   .. py:method:: __lt__(other: DPH5Path) -> bool

      
      Whether this DPPath is less than other for sorting.
















      ..
          !! processed by numpydoc !!


   .. py:method:: __str__() -> str

      
      Returns path of self.
















      ..
          !! processed by numpydoc !!


   .. py:property:: name
      :type: str


      
      Name of the path.
















      ..
          !! processed by numpydoc !!


   .. py:method:: mkdir(parents: bool = False, exist_ok: bool = False) -> None

      
      Make directory.


      :Parameters:

          **parents** : :ref:`bool <python:bltin-boolean-values>`, :obj:`optional`
              If true, any missing parents of this directory are created as well.

          **exist_ok** : :ref:`bool <python:bltin-boolean-values>`, :obj:`optional`
              If true, no error will be raised if the target directory already exists.














      ..
          !! processed by numpydoc !!


.. py:class:: DPOSPath(path: Union[str, pathlib.Path], mode: str = 'r')

   Bases: :py:obj:`DPPath`


   
   The OS path class to data system (DeepmdData) for real directories.


   :Parameters:

       **path** : :obj:`Union <typing.Union>`\[:class:`python:str`, :obj:`Path`]
           path

       **mode** : :class:`python:str`, :obj:`optional`
           mode, by default "r"














   ..
       !! processed by numpydoc !!

   .. py:attribute:: mode
      :value: 'r'



   .. py:attribute:: path


   .. py:method:: load_numpy() -> numpy.ndarray

      
      Load NumPy array.





      :Returns:

          :obj:`np.ndarray <numpy.ndarray>`
              loaded NumPy array











      ..
          !! processed by numpydoc !!


   .. py:method:: load_txt(**kwargs) -> numpy.ndarray

      
      Load NumPy array from text.





      :Returns:

          :obj:`np.ndarray <numpy.ndarray>`
              loaded NumPy array











      ..
          !! processed by numpydoc !!


   .. py:method:: save_numpy(arr: numpy.ndarray) -> None

      
      Save NumPy array.


      :Parameters:

          **arr** : :obj:`np.ndarray <numpy.ndarray>`
              NumPy array














      ..
          !! processed by numpydoc !!


   .. py:method:: glob(pattern: str) -> list[DPPath]

      
      Search path using the glob pattern.


      :Parameters:

          **pattern** : :class:`python:str`
              glob pattern



      :Returns:

          :class:`python:list`\[:obj:`DPPath`]
              list of paths











      ..
          !! processed by numpydoc !!


   .. py:method:: rglob(pattern: str) -> list[DPPath]

      
      This is like calling :meth:`DPPath.glob()` with `**/` added in front
      of the given relative pattern.


      :Parameters:

          **pattern** : :class:`python:str`
              glob pattern



      :Returns:

          :class:`python:list`\[:obj:`DPPath`]
              list of paths











      ..
          !! processed by numpydoc !!


   .. py:method:: is_file() -> bool

      
      Check if self is file.
















      ..
          !! processed by numpydoc !!


   .. py:method:: is_dir() -> bool

      
      Check if self is directory.
















      ..
          !! processed by numpydoc !!


   .. py:method:: __truediv__(key: str) -> DPPath

      
      Used for / operator.
















      ..
          !! processed by numpydoc !!


   .. py:method:: __lt__(other: DPOSPath) -> bool

      
      Whether this DPPath is less than other for sorting.
















      ..
          !! processed by numpydoc !!


   .. py:method:: __str__() -> str

      
      Represent string.
















      ..
          !! processed by numpydoc !!


   .. py:property:: name
      :type: str


      
      Name of the path.
















      ..
          !! processed by numpydoc !!


   .. py:method:: mkdir(parents: bool = False, exist_ok: bool = False) -> None

      
      Make directory.


      :Parameters:

          **parents** : :ref:`bool <python:bltin-boolean-values>`, :obj:`optional`
              If true, any missing parents of this directory are created as well.

          **exist_ok** : :ref:`bool <python:bltin-boolean-values>`, :obj:`optional`
              If true, no error will be raised if the target directory already exists.














      ..
          !! processed by numpydoc !!


.. py:class:: DPPath

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


   
   The path class to data system (DeepmdData).


   :Parameters:

       **path** : :class:`python:str`
           path

       **mode** : :class:`python:str`, :obj:`optional`
           mode, by default "r"














   ..
       !! processed by numpydoc !!

   .. py:method:: load_numpy() -> numpy.ndarray
      :abstractmethod:


      
      Load NumPy array.





      :Returns:

          :obj:`np.ndarray <numpy.ndarray>`
              loaded NumPy array











      ..
          !! processed by numpydoc !!


   .. py:method:: load_txt(**kwargs) -> numpy.ndarray
      :abstractmethod:


      
      Load NumPy array from text.





      :Returns:

          :obj:`np.ndarray <numpy.ndarray>`
              loaded NumPy array











      ..
          !! processed by numpydoc !!


   .. py:method:: save_numpy(arr: numpy.ndarray) -> None
      :abstractmethod:


      
      Save NumPy array.


      :Parameters:

          **arr** : :obj:`np.ndarray <numpy.ndarray>`
              NumPy array














      ..
          !! processed by numpydoc !!


   .. py:method:: glob(pattern: str) -> list[DPPath]
      :abstractmethod:


      
      Search path using the glob pattern.


      :Parameters:

          **pattern** : :class:`python:str`
              glob pattern



      :Returns:

          :class:`python:list`\[:obj:`DPPath`]
              list of paths











      ..
          !! processed by numpydoc !!


   .. py:method:: rglob(pattern: str) -> list[DPPath]
      :abstractmethod:


      
      This is like calling :meth:`DPPath.glob()` with `**/` added in front
      of the given relative pattern.


      :Parameters:

          **pattern** : :class:`python:str`
              glob pattern



      :Returns:

          :class:`python:list`\[:obj:`DPPath`]
              list of paths











      ..
          !! processed by numpydoc !!


   .. py:method:: is_file() -> bool
      :abstractmethod:


      
      Check if self is file.
















      ..
          !! processed by numpydoc !!


   .. py:method:: is_dir() -> bool
      :abstractmethod:


      
      Check if self is directory.
















      ..
          !! processed by numpydoc !!


   .. py:method:: __truediv__(key: str) -> DPPath
      :abstractmethod:


      
      Used for / operator.
















      ..
          !! processed by numpydoc !!


   .. py:method:: __lt__(other: DPPath) -> bool
      :abstractmethod:


      
      Whether this DPPath is less than other for sorting.
















      ..
          !! processed by numpydoc !!


   .. py:method:: __str__() -> str
      :abstractmethod:


      
      Represent string.
















      ..
          !! processed by numpydoc !!


   .. py:method:: __repr__() -> str


   .. py:method:: __eq__(other) -> bool


   .. py:method:: __hash__()


   .. py:property:: name
      :type: str

      :abstractmethod:


      
      Name of the path.
















      ..
          !! processed by numpydoc !!


   .. py:method:: mkdir(parents: bool = False, exist_ok: bool = False) -> None
      :abstractmethod:


      
      Make directory.


      :Parameters:

          **parents** : :ref:`bool <python:bltin-boolean-values>`, :obj:`optional`
              If true, any missing parents of this directory are created as well.

          **exist_ok** : :ref:`bool <python:bltin-boolean-values>`, :obj:`optional`
              If true, no error will be raised if the target directory already exists.














      ..
          !! processed by numpydoc !!


