deepmd.tf.utils.path#

Alias for backward compatibility.

Classes#

DPH5Path

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

DPOSPath

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

DPPath

The path class to data system (DeepmdData).

Module Contents#

class deepmd.tf.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

mode = 'r'#
root_path#
root#
_name#
__getnewargs__()[source]#

Return the arguments to be passed to __new__ when unpickling an instance.

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

property _keys: list[str]#

Walk all groups and dataset.

__file_new_keys: ClassVar[dict[h5py.File, list[str]]]#
property _new_keys#

New keys that haven’t been cached.

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.

property name: str#

Name of the path.

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.tf.utils.path.DPOSPath(path: str | pathlib.Path, mode: str = 'r')[source]#

Bases: DPPath

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

Parameters:
pathUnion[str, Path]

path

modestr, optional

mode, by default “r”

mode = 'r'#
path#
__getnewargs__()[source]#

Return the arguments to be passed to __new__ when unpickling an instance.

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.

property name: str#

Name of the path.

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.tf.utils.path.DPPath[source]#

Bases: abc.ABC

The path class to data system (DeepmdData).

Parameters:
pathstr

path

modestr, optional

mode, by default “r”

abstractmethod load_numpy() numpy.ndarray[source]#

Load NumPy array.

Returns:
np.ndarray

loaded NumPy array

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

Load NumPy array from text.

Returns:
np.ndarray

loaded NumPy array

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

Save NumPy array.

Parameters:
arrnp.ndarray

NumPy array

abstractmethod glob(pattern: str) list[DPPath][source]#

Search path using the glob pattern.

Parameters:
patternstr

glob pattern

Returns:
list[DPPath]

list of paths

abstractmethod 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

abstractmethod is_file() bool[source]#

Check if self is file.

abstractmethod is_dir() bool[source]#

Check if self is directory.

abstractmethod __getnewargs__()[source]#

Return the arguments to be passed to __new__ when unpickling an instance.

abstractmethod __truediv__(key: str) DPPath[source]#

Used for / operator.

abstractmethod __lt__(other: DPPath) bool[source]#

Whether this DPPath is less than other for sorting.

abstractmethod __str__() str[source]#

Represent string.

__repr__() str[source]#
__eq__(other) bool[source]#
__hash__()[source]#
property name: str#
Abstractmethod:

Name of the path.

abstractmethod 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.