deepmd.utils.path

Module Contents

Classes

DPPath

The path class to data system (DeepmdData).

DPOSPath

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

DPH5Path

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

class deepmd.utils.path.DPPath[source]

Bases: abc.ABC

The path class to data system (DeepmdData).

Parameters:
pathstr

path

modestr, optional

mode, by default “r”

abstract property name: str[source]

Name of the path.

abstract load_numpy() numpy.ndarray[source]

Load NumPy array.

Returns:
np.ndarray

loaded NumPy array

abstract load_txt(**kwargs) numpy.ndarray[source]

Load NumPy array from text.

Returns:
np.ndarray

loaded NumPy array

abstract save_numpy(arr: numpy.ndarray) None[source]

Save NumPy array.

Parameters:
arrnp.ndarray

NumPy array

abstract glob(pattern: str) List[DPPath][source]

Search path using the glob pattern.

Parameters:
patternstr

glob pattern

Returns:
List[DPPath]

list of paths

abstract rglob(pattern: str) List[DPPath][source]

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

Parameters:
patternstr

glob pattern

Returns:
List[DPPath]

list of paths

abstract is_file() bool[source]

Check if self is file.

abstract is_dir() bool[source]

Check if self is directory.

abstract __truediv__(key: str) DPPath[source]

Used for / operator.

abstract __lt__(other: DPPath) bool[source]

Whether this DPPath is less than other for sorting.

abstract __str__() str[source]

Represent string.

__repr__() str[source]

Return repr(self).

__eq__(other) bool[source]

Return self==value.

__hash__()[source]

Return hash(self).

abstract mkdir(parents: bool = False, exist_ok: bool = False) None[source]

Make directory.

Parameters:
parentsbool, optional

If true, any missing parents of this directory are created as well.

exist_okbool, optional

If true, no error will be raised if the target directory already exists.

class deepmd.utils.path.DPOSPath(path: str, mode: str = 'r')[source]

Bases: DPPath

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

Parameters:
pathstr

path

modestr, optional

mode, by default “r”

property name: str[source]

Name of the path.

load_numpy() numpy.ndarray[source]

Load NumPy array.

Returns:
np.ndarray

loaded NumPy array

load_txt(**kwargs) numpy.ndarray[source]

Load NumPy array from text.

Returns:
np.ndarray

loaded NumPy array

save_numpy(arr: numpy.ndarray) None[source]

Save NumPy array.

Parameters:
arrnp.ndarray

NumPy array

glob(pattern: str) List[DPPath][source]

Search path using the glob pattern.

Parameters:
patternstr

glob pattern

Returns:
List[DPPath]

list of paths

rglob(pattern: str) List[DPPath][source]

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

Parameters:
patternstr

glob pattern

Returns:
List[DPPath]

list of paths

is_file() bool[source]

Check if self is file.

is_dir() bool[source]

Check if self is directory.

__truediv__(key: str) DPPath[source]

Used for / operator.

__lt__(other: DPOSPath) bool[source]

Whether this DPPath is less than other for sorting.

__str__() str[source]

Represent string.

mkdir(parents: bool = False, exist_ok: bool = False) None[source]

Make directory.

Parameters:
parentsbool, optional

If true, any missing parents of this directory are created as well.

exist_okbool, optional

If true, no error will be raised if the target directory already exists.

class deepmd.utils.path.DPH5Path(path: str, mode: str = 'r')[source]

Bases: DPPath

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

Parameters:
pathstr

path

modestr, optional

mode, by default “r”

Notes

OS - HDF5 relationship:

directory - Group file - Dataset

property _keys: List[str][source]

Walk all groups and dataset.

property _new_keys[source]

New keys that haven’t been cached.

property name: str[source]

Name of the path.

__file_new_keys: ClassVar[Dict[h5py.File, List[str]]][source]
classmethod _load_h5py(path: str, mode: str = 'r') h5py.File[source]

Load hdf5 file.

Parameters:
pathstr

path to hdf5 file

modestr, optional

mode, by default ‘r’

load_numpy() numpy.ndarray[source]

Load NumPy array.

Returns:
np.ndarray

loaded NumPy array

load_txt(dtype: numpy.dtype | None = None, **kwargs) numpy.ndarray[source]

Load NumPy array from text.

Returns:
np.ndarray

loaded NumPy array

save_numpy(arr: numpy.ndarray) None[source]

Save NumPy array.

Parameters:
arrnp.ndarray

NumPy array

glob(pattern: str) List[DPPath][source]

Search path using the glob pattern.

Parameters:
patternstr

glob pattern

Returns:
List[DPPath]

list of paths

rglob(pattern: str) List[DPPath][source]

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

Parameters:
patternstr

glob pattern

Returns:
List[DPPath]

list of paths

classmethod _file_keys(file: h5py.File) List[str][source]

Walk all groups and dataset.

is_file() bool[source]

Check if self is file.

is_dir() bool[source]

Check if self is directory.

__truediv__(key: str) DPPath[source]

Used for / operator.

_connect_path(path: str) str[source]

Connect self with path.

__lt__(other: DPH5Path) bool[source]

Whether this DPPath is less than other for sorting.

__str__() str[source]

Returns path of self.

mkdir(parents: bool = False, exist_ok: bool = False) None[source]

Make directory.

Parameters:
parentsbool, optional

If true, any missing parents of this directory are created as well.

exist_okbool, optional

If true, no error will be raised if the target directory already exists.