diff --git a/backend/dp_backend.py b/backend/dp_backend.py index 97fa1578c7..6fc5676c01 100644 --- a/backend/dp_backend.py +++ b/backend/dp_backend.py @@ -1,11 +1,7 @@ """A PEP-517 backend to find TensorFlow.""" -from typing import ( - List, -) +from typing import List -from find_tensorflow import ( - find_tensorflow, -) +from find_tensorflow import find_tensorflow # TODO: switch to scikit_build_core after it is available from setuptools import build_meta as _orig diff --git a/backend/find_tensorflow.py b/backend/find_tensorflow.py index 52c7fc5286..163f91d798 100644 --- a/backend/find_tensorflow.py +++ b/backend/find_tensorflow.py @@ -1,27 +1,15 @@ import os import site -from importlib.machinery import ( - FileFinder, -) -from importlib.util import ( - find_spec, -) -from pathlib import ( - Path, -) -from sysconfig import ( - get_path, -) -from typing import ( - List, - Optional, - Tuple, - Union, -) - -from packaging.specifiers import ( - SpecifierSet, -) +from importlib.machinery import FileFinder +from importlib.util import find_spec +from pathlib import Path +from sysconfig import get_path +from typing import List +from typing import Optional +from typing import Tuple +from typing import Union + +from packaging.specifiers import SpecifierSet def find_tensorflow() -> Tuple[Optional[str], List[str]]: diff --git a/data/json/json2yaml.py b/data/json/json2yaml.py index 6c97771bec..5568d7196a 100644 --- a/data/json/json2yaml.py +++ b/data/json/json2yaml.py @@ -2,12 +2,8 @@ import argparse import json -from pathlib import ( - Path, -) -from warnings import ( - warn, -) +from pathlib import Path +from warnings import warn import yaml diff --git a/deepmd/__init__.py b/deepmd/__init__.py index d96d7eb4a4..a9138c5642 100644 --- a/deepmd/__init__.py +++ b/deepmd/__init__.py @@ -1,41 +1,29 @@ """Root of the deepmd package, exposes all public classes and submodules.""" try: - from importlib import ( - metadata, - ) + from importlib import metadata except ImportError: # for Python<3.8 import importlib_metadata as metadata import deepmd.utils.network as network -from . import ( - cluster, - descriptor, - fit, - loss, - nvnmd, - utils, -) -from .env import ( - set_mkl, -) -from .infer import ( - DeepEval, - DeepPotential, -) -from .infer.data_modifier import ( - DipoleChargeModifier, -) +from . import cluster +from . import descriptor +from . import fit +from . import loss +from . import nvnmd +from . import utils +from .env import set_mkl +from .infer import DeepEval +from .infer import DeepPotential +from .infer.data_modifier import DipoleChargeModifier set_mkl() try: from ._version import version as __version__ except ImportError: - from .__about__ import ( - __version__, - ) + from .__about__ import __version__ # load third-party plugins try: diff --git a/deepmd/__main__.py b/deepmd/__main__.py index 8e3011bc7b..09e38228fd 100644 --- a/deepmd/__main__.py +++ b/deepmd/__main__.py @@ -1,8 +1,6 @@ """Package dp entry point.""" -from .entrypoints.main import ( - main, -) +from .entrypoints.main import main if __name__ == "__main__": main() diff --git a/deepmd/calculator.py b/deepmd/calculator.py index 4777bc80bc..d878266468 100644 --- a/deepmd/calculator.py +++ b/deepmd/calculator.py @@ -1,30 +1,20 @@ """ASE calculator interface module.""" -from pathlib import ( - Path, -) -from typing import ( - TYPE_CHECKING, - Dict, - List, - Optional, - Union, -) - -from ase.calculators.calculator import ( - Calculator, - PropertyNotImplementedError, - all_changes, -) - -from deepmd import ( - DeepPotential, -) +from pathlib import Path +from typing import TYPE_CHECKING +from typing import Dict +from typing import List +from typing import Optional +from typing import Union + +from ase.calculators.calculator import Calculator +from ase.calculators.calculator import PropertyNotImplementedError +from ase.calculators.calculator import all_changes + +from deepmd import DeepPotential if TYPE_CHECKING: - from ase import ( - Atoms, - ) + from ase import Atoms __all__ = ["DP"] diff --git a/deepmd/cluster/__init__.py b/deepmd/cluster/__init__.py index 4cba0c10b9..c9865ac429 100644 --- a/deepmd/cluster/__init__.py +++ b/deepmd/cluster/__init__.py @@ -1,11 +1,9 @@ """Module that reads node resources, auto detects if running local or on SLURM.""" import os -from typing import ( - List, - Optional, - Tuple, -) +from typing import List +from typing import Optional +from typing import Tuple from .local import get_resource as get_local_res from .slurm import get_resource as get_slurm_res diff --git a/deepmd/cluster/local.py b/deepmd/cluster/local.py index 8ad9a83659..37379b9739 100644 --- a/deepmd/cluster/local.py +++ b/deepmd/cluster/local.py @@ -3,15 +3,11 @@ import socket import subprocess as sp import sys -from typing import ( - List, - Optional, - Tuple, -) - -from deepmd.env import ( - tf, -) +from typing import List +from typing import Optional +from typing import Tuple + +from deepmd.env import tf __all__ = ["get_gpus", "get_resource"] diff --git a/deepmd/cluster/slurm.py b/deepmd/cluster/slurm.py index 2be6b438f2..60e7b68a9e 100644 --- a/deepmd/cluster/slurm.py +++ b/deepmd/cluster/slurm.py @@ -6,17 +6,13 @@ """ import os -from typing import ( - List, - Optional, - Tuple, -) +from typing import List +from typing import Optional +from typing import Tuple import hostlist -from deepmd.cluster import ( - local, -) +from deepmd.cluster import local __all__ = ["get_resource"] diff --git a/deepmd/descriptor/__init__.py b/deepmd/descriptor/__init__.py index 3b55a4f97a..9a14bdb185 100644 --- a/deepmd/descriptor/__init__.py +++ b/deepmd/descriptor/__init__.py @@ -1,34 +1,14 @@ -from .descriptor import ( - Descriptor, -) -from .hybrid import ( - DescrptHybrid, -) -from .loc_frame import ( - DescrptLocFrame, -) -from .se_a import ( - DescrptSeA, -) -from .se_a_ebd import ( - DescrptSeAEbd, -) -from .se_a_ef import ( - DescrptSeAEf, - DescrptSeAEfLower, -) -from .se_a_mask import ( - DescrptSeAMask, -) -from .se_atten import ( - DescrptSeAtten, -) -from .se_r import ( - DescrptSeR, -) -from .se_t import ( - DescrptSeT, -) +from .descriptor import Descriptor +from .hybrid import DescrptHybrid +from .loc_frame import DescrptLocFrame +from .se_a import DescrptSeA +from .se_a_ebd import DescrptSeAEbd +from .se_a_ef import DescrptSeAEf +from .se_a_ef import DescrptSeAEfLower +from .se_a_mask import DescrptSeAMask +from .se_atten import DescrptSeAtten +from .se_r import DescrptSeR +from .se_t import DescrptSeT __all__ = [ "Descriptor", diff --git a/deepmd/descriptor/descriptor.py b/deepmd/descriptor/descriptor.py index 3542918cb3..59188a9ce0 100644 --- a/deepmd/descriptor/descriptor.py +++ b/deepmd/descriptor/descriptor.py @@ -1,25 +1,17 @@ -from abc import ( - abstractmethod, -) -from typing import ( - Any, - Callable, - Dict, - List, - Optional, - Tuple, -) +from abc import abstractmethod +from typing import Any +from typing import Callable +from typing import Dict +from typing import List +from typing import Optional +from typing import Tuple import numpy as np -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - tf, -) -from deepmd.utils import ( - Plugin, - PluginVariant, -) +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.utils import Plugin +from deepmd.utils import PluginVariant class Descriptor(PluginVariant): diff --git a/deepmd/descriptor/hybrid.py b/deepmd/descriptor/hybrid.py index e1ddf5f2e9..c89ceb5c44 100644 --- a/deepmd/descriptor/hybrid.py +++ b/deepmd/descriptor/hybrid.py @@ -1,18 +1,12 @@ -from typing import ( - List, - Optional, - Tuple, -) +from typing import List +from typing import Optional +from typing import Tuple import numpy as np -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - tf, -) -from deepmd.utils.spin import ( - Spin, -) +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.utils.spin import Spin # from deepmd.descriptor import DescrptLocFrame # from deepmd.descriptor import DescrptSeA @@ -20,9 +14,7 @@ # from deepmd.descriptor import DescrptSeAEbd # from deepmd.descriptor import DescrptSeAEf # from deepmd.descriptor import DescrptSeR -from .descriptor import ( - Descriptor, -) +from .descriptor import Descriptor @Descriptor.register("hybrid") diff --git a/deepmd/descriptor/loc_frame.py b/deepmd/descriptor/loc_frame.py index dd99f7fb57..f268208416 100644 --- a/deepmd/descriptor/loc_frame.py +++ b/deepmd/descriptor/loc_frame.py @@ -1,28 +1,18 @@ -from typing import ( - List, - Optional, - Tuple, -) +from typing import List +from typing import Optional +from typing import Tuple import numpy as np -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - default_tf_session_config, - op_module, - tf, -) -from deepmd.utils.graph import ( - get_tensor_by_name_from_graph, -) -from deepmd.utils.sess import ( - run_sess, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import default_tf_session_config +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.utils.graph import get_tensor_by_name_from_graph +from deepmd.utils.sess import run_sess -from .descriptor import ( - Descriptor, -) +from .descriptor import Descriptor @Descriptor.register("loc_frame") diff --git a/deepmd/descriptor/se.py b/deepmd/descriptor/se.py index 242ee5425d..26dcc4d5f1 100644 --- a/deepmd/descriptor/se.py +++ b/deepmd/descriptor/se.py @@ -1,18 +1,10 @@ -from typing import ( - Tuple, -) - -from deepmd.env import ( - tf, -) -from deepmd.utils.graph import ( - get_embedding_net_variables_from_graph_def, - get_tensor_by_name_from_graph, -) - -from .descriptor import ( - Descriptor, -) +from typing import Tuple + +from deepmd.env import tf +from deepmd.utils.graph import get_embedding_net_variables_from_graph_def +from deepmd.utils.graph import get_tensor_by_name_from_graph + +from .descriptor import Descriptor class DescrptSe(Descriptor): diff --git a/deepmd/descriptor/se_a_ebd.py b/deepmd/descriptor/se_a_ebd.py index e0684403e1..0b009af24d 100644 --- a/deepmd/descriptor/se_a_ebd.py +++ b/deepmd/descriptor/se_a_ebd.py @@ -1,29 +1,17 @@ -from typing import ( - List, - Optional, -) +from typing import List +from typing import Optional import numpy as np -from deepmd.common import ( - add_data_requirement, -) -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) -from deepmd.utils.network import ( - embedding_net, - one_layer, -) +from deepmd.common import add_data_requirement +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.utils.network import embedding_net +from deepmd.utils.network import one_layer -from .descriptor import ( - Descriptor, -) -from .se_a import ( - DescrptSeA, -) +from .descriptor import Descriptor +from .se_a import DescrptSeA @Descriptor.register("se_a_tpe") diff --git a/deepmd/descriptor/se_a_ef.py b/deepmd/descriptor/se_a_ef.py index 0dbad403f4..d050966175 100644 --- a/deepmd/descriptor/se_a_ef.py +++ b/deepmd/descriptor/se_a_ef.py @@ -1,31 +1,19 @@ -from typing import ( - List, - Optional, - Tuple, -) +from typing import List +from typing import Optional +from typing import Tuple import numpy as np -from deepmd.common import ( - add_data_requirement, -) -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - default_tf_session_config, - op_module, - tf, -) -from deepmd.utils.sess import ( - run_sess, -) - -from .descriptor import ( - Descriptor, -) -from .se_a import ( - DescrptSeA, -) +from deepmd.common import add_data_requirement +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import default_tf_session_config +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.utils.sess import run_sess + +from .descriptor import Descriptor +from .se_a import DescrptSeA @Descriptor.register("se_a_ef") diff --git a/deepmd/descriptor/se_a_mask.py b/deepmd/descriptor/se_a_mask.py index 93256e3910..e1f88629e4 100644 --- a/deepmd/descriptor/se_a_mask.py +++ b/deepmd/descriptor/se_a_mask.py @@ -1,35 +1,23 @@ import warnings -from typing import ( - Any, - Dict, - List, - Optional, - Tuple, -) +from typing import Any +from typing import Dict +from typing import List +from typing import Optional +from typing import Tuple import numpy as np -from deepmd.common import ( - get_activation_func, - get_precision, -) -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - default_tf_session_config, - op_module, - tf, -) -from deepmd.utils.network import ( - embedding_net_rand_seed_shift, -) - -from .descriptor import ( - Descriptor, -) -from .se_a import ( - DescrptSeA, -) +from deepmd.common import get_activation_func +from deepmd.common import get_precision +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import default_tf_session_config +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.utils.network import embedding_net_rand_seed_shift + +from .descriptor import Descriptor +from .se_a import DescrptSeA @Descriptor.register("se_a_mask") diff --git a/deepmd/descriptor/se_atten.py b/deepmd/descriptor/se_atten.py index b113e5c994..2643467f83 100644 --- a/deepmd/descriptor/se_atten.py +++ b/deepmd/descriptor/se_atten.py @@ -1,43 +1,25 @@ import warnings -from typing import ( - List, - Optional, - Tuple, -) +from typing import List +from typing import Optional +from typing import Tuple import numpy as np -from packaging.version import ( - Version, -) +from packaging.version import Version -from deepmd.common import ( - cast_precision, -) -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - TF_VERSION, - default_tf_session_config, - op_module, - tf, -) -from deepmd.utils.graph import ( - get_attention_layer_variables_from_graph_def, -) -from deepmd.utils.network import ( - embedding_net, - one_layer, -) -from deepmd.utils.sess import ( - run_sess, -) +from deepmd.common import cast_precision +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import TF_VERSION +from deepmd.env import default_tf_session_config +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.utils.graph import get_attention_layer_variables_from_graph_def +from deepmd.utils.network import embedding_net +from deepmd.utils.network import one_layer +from deepmd.utils.sess import run_sess -from .descriptor import ( - Descriptor, -) -from .se_a import ( - DescrptSeA, -) +from .descriptor import Descriptor +from .se_a import DescrptSeA @Descriptor.register("se_atten") diff --git a/deepmd/descriptor/se_r.py b/deepmd/descriptor/se_r.py index 7ef5f47347..b2afe76be1 100644 --- a/deepmd/descriptor/se_r.py +++ b/deepmd/descriptor/se_r.py @@ -1,46 +1,26 @@ -from typing import ( - List, - Optional, - Tuple, -) +from typing import List +from typing import Optional +from typing import Tuple import numpy as np -from deepmd.common import ( - cast_precision, - get_activation_func, - get_precision, -) -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - default_tf_session_config, - op_module, - tf, -) -from deepmd.utils.graph import ( - get_tensor_by_name_from_graph, -) -from deepmd.utils.network import ( - embedding_net, - embedding_net_rand_seed_shift, -) -from deepmd.utils.sess import ( - run_sess, -) -from deepmd.utils.spin import ( - Spin, -) -from deepmd.utils.tabulate import ( - DPTabulate, -) - -from .descriptor import ( - Descriptor, -) -from .se import ( - DescrptSe, -) +from deepmd.common import cast_precision +from deepmd.common import get_activation_func +from deepmd.common import get_precision +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import default_tf_session_config +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.utils.graph import get_tensor_by_name_from_graph +from deepmd.utils.network import embedding_net +from deepmd.utils.network import embedding_net_rand_seed_shift +from deepmd.utils.sess import run_sess +from deepmd.utils.spin import Spin +from deepmd.utils.tabulate import DPTabulate + +from .descriptor import Descriptor +from .se import DescrptSe @Descriptor.register("se_e2_r") diff --git a/deepmd/descriptor/se_t.py b/deepmd/descriptor/se_t.py index 7615275a82..d35b68894f 100644 --- a/deepmd/descriptor/se_t.py +++ b/deepmd/descriptor/se_t.py @@ -1,43 +1,25 @@ -from typing import ( - List, - Optional, - Tuple, -) +from typing import List +from typing import Optional +from typing import Tuple import numpy as np -from deepmd.common import ( - cast_precision, - get_activation_func, - get_precision, -) -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - default_tf_session_config, - op_module, - tf, -) -from deepmd.utils.graph import ( - get_tensor_by_name_from_graph, -) -from deepmd.utils.network import ( - embedding_net, - embedding_net_rand_seed_shift, -) -from deepmd.utils.sess import ( - run_sess, -) -from deepmd.utils.tabulate import ( - DPTabulate, -) - -from .descriptor import ( - Descriptor, -) -from .se import ( - DescrptSe, -) +from deepmd.common import cast_precision +from deepmd.common import get_activation_func +from deepmd.common import get_precision +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import default_tf_session_config +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.utils.graph import get_tensor_by_name_from_graph +from deepmd.utils.network import embedding_net +from deepmd.utils.network import embedding_net_rand_seed_shift +from deepmd.utils.sess import run_sess +from deepmd.utils.tabulate import DPTabulate + +from .descriptor import Descriptor +from .se import DescrptSe @Descriptor.register("se_e3") diff --git a/deepmd/entrypoints/__init__.py b/deepmd/entrypoints/__init__.py index fc690daf14..66405f0e0d 100644 --- a/deepmd/entrypoints/__init__.py +++ b/deepmd/entrypoints/__init__.py @@ -1,33 +1,17 @@ """Submodule that contains all the DeePMD-Kit entry point scripts.""" -from ..infer.model_devi import ( - make_model_devi, -) -from .compress import ( - compress, -) -from .convert import ( - convert, -) -from .doc import ( - doc_train_input, -) -from .freeze import ( - freeze, -) -from .neighbor_stat import ( - neighbor_stat, -) -from .test import ( - test, -) +from ..infer.model_devi import make_model_devi +from .compress import compress +from .convert import convert +from .doc import doc_train_input +from .freeze import freeze +from .neighbor_stat import neighbor_stat +from .test import test # import `train` as `train_dp` to avoid the conflict of the # module name `train` and the function name `train` from .train import train as train_dp -from .transfer import ( - transfer, -) +from .transfer import transfer __all__ = [ "doc_train_input", diff --git a/deepmd/entrypoints/compress.py b/deepmd/entrypoints/compress.py index a198127d12..ee5ce3a1e2 100644 --- a/deepmd/entrypoints/compress.py +++ b/deepmd/entrypoints/compress.py @@ -3,40 +3,22 @@ import json import logging import os -from typing import ( - Optional, -) - -from deepmd.common import ( - j_loader, -) -from deepmd.env import ( - GLOBAL_ENER_FLOAT_PRECISION, - tf, -) -from deepmd.utils.argcheck import ( - normalize, -) -from deepmd.utils.compat import ( - update_deepmd_input, -) -from deepmd.utils.errors import ( - GraphTooLargeError, - GraphWithoutTensorError, -) -from deepmd.utils.graph import ( - get_tensor_by_name_from_graph, - load_graph_def, -) - -from .freeze import ( - freeze, -) -from .train import ( - get_min_nbor_dist, - get_rcut, - train, -) +from typing import Optional + +from deepmd.common import j_loader +from deepmd.env import GLOBAL_ENER_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.utils.argcheck import normalize +from deepmd.utils.compat import update_deepmd_input +from deepmd.utils.errors import GraphTooLargeError +from deepmd.utils.errors import GraphWithoutTensorError +from deepmd.utils.graph import get_tensor_by_name_from_graph +from deepmd.utils.graph import load_graph_def + +from .freeze import freeze +from .train import get_min_nbor_dist +from .train import get_rcut +from .train import train __all__ = ["compress"] diff --git a/deepmd/entrypoints/convert.py b/deepmd/entrypoints/convert.py index b97c137104..dfd12bf4b7 100644 --- a/deepmd/entrypoints/convert.py +++ b/deepmd/entrypoints/convert.py @@ -1,12 +1,10 @@ -from deepmd.utils.convert import ( - convert_10_to_21, - convert_012_to_21, - convert_12_to_21, - convert_13_to_21, - convert_20_to_21, - convert_pbtxt_to_pb, - convert_to_21, -) +from deepmd.utils.convert import convert_10_to_21 +from deepmd.utils.convert import convert_012_to_21 +from deepmd.utils.convert import convert_12_to_21 +from deepmd.utils.convert import convert_13_to_21 +from deepmd.utils.convert import convert_20_to_21 +from deepmd.utils.convert import convert_pbtxt_to_pb +from deepmd.utils.convert import convert_to_21 def convert( diff --git a/deepmd/entrypoints/doc.py b/deepmd/entrypoints/doc.py index b439c17409..42fcca983c 100644 --- a/deepmd/entrypoints/doc.py +++ b/deepmd/entrypoints/doc.py @@ -1,9 +1,7 @@ """Module that prints train input arguments docstrings.""" -from deepmd.utils.argcheck import ( - gen_doc, - gen_json, -) +from deepmd.utils.argcheck import gen_doc +from deepmd.utils.argcheck import gen_json __all__ = ["doc_train_input"] diff --git a/deepmd/entrypoints/ipi.py b/deepmd/entrypoints/ipi.py index 4208e7f56d..55378975cd 100644 --- a/deepmd/entrypoints/ipi.py +++ b/deepmd/entrypoints/ipi.py @@ -2,13 +2,9 @@ import os import subprocess import sys -from typing import ( - List, -) +from typing import List -from deepmd.lmp import ( - get_op_dir, -) +from deepmd.lmp import get_op_dir ROOT_DIR = get_op_dir() diff --git a/deepmd/entrypoints/neighbor_stat.py b/deepmd/entrypoints/neighbor_stat.py index 226f312621..bfc17fdea6 100644 --- a/deepmd/entrypoints/neighbor_stat.py +++ b/deepmd/entrypoints/neighbor_stat.py @@ -1,17 +1,9 @@ import logging -from typing import ( - List, -) +from typing import List -from deepmd.common import ( - expand_sys_str, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) -from deepmd.utils.neighbor_stat import ( - NeighborStat, -) +from deepmd.common import expand_sys_str +from deepmd.utils.data_system import DeepmdDataSystem +from deepmd.utils.neighbor_stat import NeighborStat log = logging.getLogger(__name__) diff --git a/deepmd/entrypoints/transfer.py b/deepmd/entrypoints/transfer.py index 8eeeb10653..a067353e2c 100644 --- a/deepmd/entrypoints/transfer.py +++ b/deepmd/entrypoints/transfer.py @@ -2,18 +2,14 @@ import logging import re -from typing import ( - Dict, - Optional, - Sequence, -) +from typing import Dict +from typing import Optional +from typing import Sequence import numpy as np -from deepmd.env import ( - TRANSFER_PATTERN, - tf, -) +from deepmd.env import TRANSFER_PATTERN +from deepmd.env import tf __all__ = ["transfer"] diff --git a/deepmd/fit/__init__.py b/deepmd/fit/__init__.py index 875c67cd5d..d5529c80e6 100644 --- a/deepmd/fit/__init__.py +++ b/deepmd/fit/__init__.py @@ -1,19 +1,9 @@ -from .dipole import ( - DipoleFittingSeA, -) -from .dos import ( - DOSFitting, -) -from .ener import ( - EnerFitting, -) -from .fitting import ( - Fitting, -) -from .polar import ( - GlobalPolarFittingSeA, - PolarFittingSeA, -) +from .dipole import DipoleFittingSeA +from .dos import DOSFitting +from .ener import EnerFitting +from .fitting import Fitting +from .polar import GlobalPolarFittingSeA +from .polar import PolarFittingSeA __all__ = [ "DipoleFittingSeA", diff --git a/deepmd/fit/dipole.py b/deepmd/fit/dipole.py index 9f497584ae..52d68af480 100644 --- a/deepmd/fit/dipole.py +++ b/deepmd/fit/dipole.py @@ -1,28 +1,16 @@ -from typing import ( - List, - Optional, -) +from typing import List +from typing import Optional import numpy as np -from deepmd.common import ( - cast_precision, - get_activation_func, - get_precision, -) -from deepmd.env import ( - tf, -) -from deepmd.fit.fitting import ( - Fitting, -) -from deepmd.utils.graph import ( - get_fitting_net_variables_from_graph_def, -) -from deepmd.utils.network import ( - one_layer, - one_layer_rand_seed_shift, -) +from deepmd.common import cast_precision +from deepmd.common import get_activation_func +from deepmd.common import get_precision +from deepmd.env import tf +from deepmd.fit.fitting import Fitting +from deepmd.utils.graph import get_fitting_net_variables_from_graph_def +from deepmd.utils.network import one_layer +from deepmd.utils.network import one_layer_rand_seed_shift @Fitting.register("dipole") diff --git a/deepmd/fit/dos.py b/deepmd/fit/dos.py index 4bb1838af1..fa43634c16 100644 --- a/deepmd/fit/dos.py +++ b/deepmd/fit/dos.py @@ -1,41 +1,23 @@ import logging -from typing import ( - List, - Optional, -) +from typing import List +from typing import Optional import numpy as np -from deepmd.common import ( - add_data_requirement, - cast_precision, - get_activation_func, - get_precision, -) -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - tf, -) -from deepmd.fit.fitting import ( - Fitting, -) -from deepmd.nvnmd.fit.ener import ( - one_layer_nvnmd, -) -from deepmd.nvnmd.utils.config import ( - nvnmd_cfg, -) -from deepmd.utils.errors import ( - GraphWithoutTensorError, -) -from deepmd.utils.graph import ( - get_fitting_net_variables_from_graph_def, - get_tensor_by_name_from_graph, -) +from deepmd.common import add_data_requirement +from deepmd.common import cast_precision +from deepmd.common import get_activation_func +from deepmd.common import get_precision +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.fit.fitting import Fitting +from deepmd.nvnmd.fit.ener import one_layer_nvnmd +from deepmd.nvnmd.utils.config import nvnmd_cfg +from deepmd.utils.errors import GraphWithoutTensorError +from deepmd.utils.graph import get_fitting_net_variables_from_graph_def +from deepmd.utils.graph import get_tensor_by_name_from_graph from deepmd.utils.network import one_layer as one_layer_deepmd -from deepmd.utils.network import ( - one_layer_rand_seed_shift, -) +from deepmd.utils.network import one_layer_rand_seed_shift log = logging.getLogger(__name__) diff --git a/deepmd/fit/fitting.py b/deepmd/fit/fitting.py index b0a9efe3be..a2fd225c9c 100644 --- a/deepmd/fit/fitting.py +++ b/deepmd/fit/fitting.py @@ -1,14 +1,8 @@ -from typing import ( - Callable, -) +from typing import Callable -from deepmd.env import ( - tf, -) -from deepmd.utils import ( - Plugin, - PluginVariant, -) +from deepmd.env import tf +from deepmd.utils import Plugin +from deepmd.utils import PluginVariant class Fitting(PluginVariant): diff --git a/deepmd/fit/polar.py b/deepmd/fit/polar.py index 42b8d155f5..8a36aa4ea5 100644 --- a/deepmd/fit/polar.py +++ b/deepmd/fit/polar.py @@ -1,32 +1,18 @@ import warnings -from typing import ( - List, - Optional, -) +from typing import List +from typing import Optional import numpy as np -from deepmd.common import ( - cast_precision, - get_activation_func, - get_precision, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit.fitting import ( - Fitting, -) -from deepmd.utils.graph import ( - get_fitting_net_variables_from_graph_def, -) -from deepmd.utils.network import ( - one_layer, - one_layer_rand_seed_shift, -) +from deepmd.common import cast_precision +from deepmd.common import get_activation_func +from deepmd.common import get_precision +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit.fitting import Fitting +from deepmd.utils.graph import get_fitting_net_variables_from_graph_def +from deepmd.utils.network import one_layer +from deepmd.utils.network import one_layer_rand_seed_shift @Fitting.register("polar") diff --git a/deepmd/infer/__init__.py b/deepmd/infer/__init__.py index f87541c889..e974411ed9 100644 --- a/deepmd/infer/__init__.py +++ b/deepmd/infer/__init__.py @@ -1,40 +1,18 @@ """Submodule containing all the implemented potentials.""" -from pathlib import ( - Path, -) -from typing import ( - Union, -) +from pathlib import Path +from typing import Union -from .data_modifier import ( - DipoleChargeModifier, -) -from .deep_dipole import ( - DeepDipole, -) -from .deep_dos import ( - DeepDOS, -) -from .deep_eval import ( - DeepEval, -) -from .deep_polar import ( - DeepGlobalPolar, - DeepPolar, -) -from .deep_pot import ( - DeepPot, -) -from .deep_wfc import ( - DeepWFC, -) -from .ewald_recp import ( - EwaldRecp, -) -from .model_devi import ( - calc_model_devi, -) +from .data_modifier import DipoleChargeModifier +from .deep_dipole import DeepDipole +from .deep_dos import DeepDOS +from .deep_eval import DeepEval +from .deep_polar import DeepGlobalPolar +from .deep_polar import DeepPolar +from .deep_pot import DeepPot +from .deep_wfc import DeepWFC +from .ewald_recp import EwaldRecp +from .model_devi import calc_model_devi __all__ = [ "DeepPotential", diff --git a/deepmd/infer/data_modifier.py b/deepmd/infer/data_modifier.py index 2da80c572b..a552cc5b16 100644 --- a/deepmd/infer/data_modifier.py +++ b/deepmd/infer/data_modifier.py @@ -1,32 +1,18 @@ import os -from typing import ( - List, - Tuple, -) +from typing import List +from typing import Tuple import numpy as np -from deepmd.common import ( - make_default_mesh, - select_idx_map, -) -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) -from deepmd.infer.deep_dipole import ( - DeepDipole, -) -from deepmd.infer.ewald_recp import ( - EwaldRecp, -) -from deepmd.utils.data import ( - DeepmdData, -) -from deepmd.utils.sess import ( - run_sess, -) +from deepmd.common import make_default_mesh +from deepmd.common import select_idx_map +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.infer.deep_dipole import DeepDipole +from deepmd.infer.ewald_recp import EwaldRecp +from deepmd.utils.data import DeepmdData +from deepmd.utils.sess import run_sess class DipoleChargeModifier(DeepDipole): diff --git a/deepmd/infer/deep_dipole.py b/deepmd/infer/deep_dipole.py index e7eb1061de..4b2384a152 100644 --- a/deepmd/infer/deep_dipole.py +++ b/deepmd/infer/deep_dipole.py @@ -1,15 +1,9 @@ -from typing import ( - TYPE_CHECKING, -) +from typing import TYPE_CHECKING -from deepmd.infer.deep_tensor import ( - DeepTensor, -) +from deepmd.infer.deep_tensor import DeepTensor if TYPE_CHECKING: - from pathlib import ( - Path, - ) + from pathlib import Path class DeepDipole(DeepTensor): diff --git a/deepmd/infer/deep_dos.py b/deepmd/infer/deep_dos.py index 2f6dc83d00..eb18c3fe69 100644 --- a/deepmd/infer/deep_dos.py +++ b/deepmd/infer/deep_dos.py @@ -1,32 +1,20 @@ import logging -from typing import ( - TYPE_CHECKING, - Callable, - List, - Optional, - Tuple, - Union, -) +from typing import TYPE_CHECKING +from typing import Callable +from typing import List +from typing import Optional +from typing import Tuple +from typing import Union import numpy as np -from deepmd.common import ( - make_default_mesh, -) -from deepmd.infer.deep_eval import ( - DeepEval, -) -from deepmd.utils.batch_size import ( - AutoBatchSize, -) -from deepmd.utils.sess import ( - run_sess, -) +from deepmd.common import make_default_mesh +from deepmd.infer.deep_eval import DeepEval +from deepmd.utils.batch_size import AutoBatchSize +from deepmd.utils.sess import run_sess if TYPE_CHECKING: - from pathlib import ( - Path, - ) + from pathlib import Path log = logging.getLogger(__name__) diff --git a/deepmd/infer/deep_polar.py b/deepmd/infer/deep_polar.py index f08ea9f64b..6cb58cff7c 100644 --- a/deepmd/infer/deep_polar.py +++ b/deepmd/infer/deep_polar.py @@ -1,19 +1,13 @@ -from typing import ( - TYPE_CHECKING, - List, - Optional, -) +from typing import TYPE_CHECKING +from typing import List +from typing import Optional import numpy as np -from deepmd.infer.deep_tensor import ( - DeepTensor, -) +from deepmd.infer.deep_tensor import DeepTensor if TYPE_CHECKING: - from pathlib import ( - Path, - ) + from pathlib import Path class DeepPolar(DeepTensor): diff --git a/deepmd/infer/deep_tensor.py b/deepmd/infer/deep_tensor.py index ca62b97385..8b31d91b2d 100644 --- a/deepmd/infer/deep_tensor.py +++ b/deepmd/infer/deep_tensor.py @@ -1,26 +1,16 @@ -from typing import ( - TYPE_CHECKING, - List, - Optional, - Tuple, -) +from typing import TYPE_CHECKING +from typing import List +from typing import Optional +from typing import Tuple import numpy as np -from deepmd.common import ( - make_default_mesh, -) -from deepmd.infer.deep_eval import ( - DeepEval, -) -from deepmd.utils.sess import ( - run_sess, -) +from deepmd.common import make_default_mesh +from deepmd.infer.deep_eval import DeepEval +from deepmd.utils.sess import run_sess if TYPE_CHECKING: - from pathlib import ( - Path, - ) + from pathlib import Path class DeepTensor(DeepEval): diff --git a/deepmd/infer/deep_wfc.py b/deepmd/infer/deep_wfc.py index 36a77de35e..090ead5a33 100644 --- a/deepmd/infer/deep_wfc.py +++ b/deepmd/infer/deep_wfc.py @@ -1,15 +1,9 @@ -from typing import ( - TYPE_CHECKING, -) +from typing import TYPE_CHECKING -from deepmd.infer.deep_tensor import ( - DeepTensor, -) +from deepmd.infer.deep_tensor import DeepTensor if TYPE_CHECKING: - from pathlib import ( - Path, - ) + from pathlib import Path class DeepWFC(DeepTensor): diff --git a/deepmd/infer/ewald_recp.py b/deepmd/infer/ewald_recp.py index 6db1d63520..405756d7a7 100644 --- a/deepmd/infer/ewald_recp.py +++ b/deepmd/infer/ewald_recp.py @@ -1,18 +1,12 @@ -from typing import ( - Tuple, -) +from typing import Tuple import numpy as np -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - default_tf_session_config, - op_module, - tf, -) -from deepmd.utils.sess import ( - run_sess, -) +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import default_tf_session_config +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.utils.sess import run_sess class EwaldRecp: diff --git a/deepmd/infer/model_devi.py b/deepmd/infer/model_devi.py index 114fb14f30..8736573d73 100644 --- a/deepmd/infer/model_devi.py +++ b/deepmd/infer/model_devi.py @@ -1,22 +1,12 @@ -from typing import ( - Tuple, -) +from typing import Tuple import numpy as np -from deepmd.common import ( - expand_sys_str, -) - -from ..utils.batch_size import ( - AutoBatchSize, -) -from ..utils.data import ( - DeepmdData, -) -from .deep_pot import ( - DeepPot, -) +from deepmd.common import expand_sys_str + +from ..utils.batch_size import AutoBatchSize +from ..utils.data import DeepmdData +from .deep_pot import DeepPot def calc_model_devi_f(fs: np.ndarray) -> Tuple[np.ndarray]: diff --git a/deepmd/lmp.py b/deepmd/lmp.py index 72321832af..0f6be85f04 100644 --- a/deepmd/lmp.py +++ b/deepmd/lmp.py @@ -1,30 +1,18 @@ """Register entry points for lammps-wheel.""" import os import platform -from importlib import ( - import_module, -) -from pathlib import ( - Path, -) -from typing import ( - List, - Optional, -) +from importlib import import_module +from pathlib import Path +from typing import List +from typing import Optional -from packaging.version import ( - Version, -) +from packaging.version import Version -from deepmd.env import ( - TF_VERSION, - tf, -) +from deepmd.env import TF_VERSION +from deepmd.env import tf if Version(TF_VERSION) < Version("2.12"): - from find_libpython import ( - find_libpython, - ) + from find_libpython import find_libpython else: find_libpython = None diff --git a/deepmd/loggers/__init__.py b/deepmd/loggers/__init__.py index f9cf3087e6..8eb1868ae3 100644 --- a/deepmd/loggers/__init__.py +++ b/deepmd/loggers/__init__.py @@ -1,7 +1,5 @@ """Module taking care of logging duties.""" -from .loggers import ( - set_log_handles, -) +from .loggers import set_log_handles __all__ = ["set_log_handles"] diff --git a/deepmd/loggers/loggers.py b/deepmd/loggers/loggers.py index 9fe9530482..3fff9fd2fd 100644 --- a/deepmd/loggers/loggers.py +++ b/deepmd/loggers/loggers.py @@ -2,19 +2,13 @@ import logging import os -from typing import ( - TYPE_CHECKING, - Optional, -) +from typing import TYPE_CHECKING +from typing import Optional if TYPE_CHECKING: - from pathlib import ( - Path, - ) + from pathlib import Path - from mpi4py import ( - MPI, - ) + from mpi4py import MPI _MPI_APPEND_MODE = MPI.MODE_CREATE | MPI.MODE_APPEND @@ -206,9 +200,7 @@ def set_log_handles( MPI = None if mpi_log: try: - from mpi4py import ( - MPI, - ) + from mpi4py import MPI except ImportError as e: raise RuntimeError( "You cannot specify 'mpi_log' when mpi4py not installed" diff --git a/deepmd/loss/__init__.py b/deepmd/loss/__init__.py index bfd6e57397..d4d82a1c69 100644 --- a/deepmd/loss/__init__.py +++ b/deepmd/loss/__init__.py @@ -1,14 +1,8 @@ -from .dos import ( - DOSLoss, -) -from .ener import ( - EnerDipoleLoss, - EnerSpinLoss, - EnerStdLoss, -) -from .tensor import ( - TensorLoss, -) +from .dos import DOSLoss +from .ener import EnerDipoleLoss +from .ener import EnerSpinLoss +from .ener import EnerStdLoss +from .tensor import TensorLoss __all__ = [ "EnerDipoleLoss", diff --git a/deepmd/loss/dos.py b/deepmd/loss/dos.py index 5a7e67e29c..3373345a95 100644 --- a/deepmd/loss/dos.py +++ b/deepmd/loss/dos.py @@ -1,20 +1,12 @@ import numpy as np -from deepmd.common import ( - add_data_requirement, -) -from deepmd.env import ( - global_cvt_2_ener_float, - global_cvt_2_tf_float, - tf, -) -from deepmd.utils.sess import ( - run_sess, -) - -from .loss import ( - Loss, -) +from deepmd.common import add_data_requirement +from deepmd.env import global_cvt_2_ener_float +from deepmd.env import global_cvt_2_tf_float +from deepmd.env import tf +from deepmd.utils.sess import run_sess + +from .loss import Loss class DOSLoss(Loss): diff --git a/deepmd/loss/tensor.py b/deepmd/loss/tensor.py index e261be2bb1..ff28b78ed5 100644 --- a/deepmd/loss/tensor.py +++ b/deepmd/loss/tensor.py @@ -1,19 +1,11 @@ import numpy as np -from deepmd.common import ( - add_data_requirement, -) -from deepmd.env import ( - global_cvt_2_tf_float, - tf, -) -from deepmd.utils.sess import ( - run_sess, -) - -from .loss import ( - Loss, -) +from deepmd.common import add_data_requirement +from deepmd.env import global_cvt_2_tf_float +from deepmd.env import tf +from deepmd.utils.sess import run_sess + +from .loss import Loss class TensorLoss(Loss): diff --git a/deepmd/model/__init__.py b/deepmd/model/__init__.py index 43f4b4a3a9..423b6d2bcb 100644 --- a/deepmd/model/__init__.py +++ b/deepmd/model/__init__.py @@ -1,18 +1,10 @@ -from .dos import ( - DOSModel, -) -from .ener import ( - EnerModel, -) -from .multi import ( - MultiModel, -) -from .tensor import ( - DipoleModel, - GlobalPolarModel, - PolarModel, - WFCModel, -) +from .dos import DOSModel +from .ener import EnerModel +from .multi import MultiModel +from .tensor import DipoleModel +from .tensor import GlobalPolarModel +from .tensor import PolarModel +from .tensor import WFCModel __all__ = [ "EnerModel", diff --git a/deepmd/model/dos.py b/deepmd/model/dos.py index 0da709409f..911104433e 100644 --- a/deepmd/model/dos.py +++ b/deepmd/model/dos.py @@ -1,21 +1,13 @@ -from typing import ( - List, - Optional, -) - -from deepmd.env import ( - MODEL_VERSION, - global_cvt_2_ener_float, - tf, -) - -from .model import ( - Model, -) -from .model_stat import ( - make_stat_input, - merge_sys_stat, -) +from typing import List +from typing import Optional + +from deepmd.env import MODEL_VERSION +from deepmd.env import global_cvt_2_ener_float +from deepmd.env import tf + +from .model import Model +from .model_stat import make_stat_input +from .model_stat import merge_sys_stat class DOSModel(Model): diff --git a/deepmd/model/model_stat.py b/deepmd/model/model_stat.py index 28f0eb4f1d..764f592414 100644 --- a/deepmd/model/model_stat.py +++ b/deepmd/model/model_stat.py @@ -1,6 +1,4 @@ -from collections import ( - defaultdict, -) +from collections import defaultdict import numpy as np diff --git a/deepmd/model/multi.py b/deepmd/model/multi.py index dcf7566f36..7e616d050e 100644 --- a/deepmd/model/multi.py +++ b/deepmd/model/multi.py @@ -1,31 +1,19 @@ import json -from typing import ( - List, - Optional, -) +from typing import List +from typing import Optional import numpy as np -from deepmd.env import ( - MODEL_VERSION, - global_cvt_2_ener_float, - op_module, - tf, -) -from deepmd.utils.graph import ( - get_tensor_by_name_from_graph, -) -from deepmd.utils.pair_tab import ( - PairTab, -) - -from .model import ( - Model, -) -from .model_stat import ( - make_stat_input, - merge_sys_stat, -) +from deepmd.env import MODEL_VERSION +from deepmd.env import global_cvt_2_ener_float +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.utils.graph import get_tensor_by_name_from_graph +from deepmd.utils.pair_tab import PairTab + +from .model import Model +from .model_stat import make_stat_input +from .model_stat import merge_sys_stat class MultiModel(Model): diff --git a/deepmd/model/tensor.py b/deepmd/model/tensor.py index eb32fa88cf..bff3af526f 100644 --- a/deepmd/model/tensor.py +++ b/deepmd/model/tensor.py @@ -1,20 +1,12 @@ -from typing import ( - List, - Optional, -) - -from deepmd.env import ( - MODEL_VERSION, - tf, -) - -from .model import ( - Model, -) -from .model_stat import ( - make_stat_input, - merge_sys_stat, -) +from typing import List +from typing import Optional + +from deepmd.env import MODEL_VERSION +from deepmd.env import tf + +from .model import Model +from .model_stat import make_stat_input +from .model_stat import merge_sys_stat class TensorModel(Model): diff --git a/deepmd/nvnmd/__init__.py b/deepmd/nvnmd/__init__.py index f598ff416a..bb3be2895b 100644 --- a/deepmd/nvnmd/__init__.py +++ b/deepmd/nvnmd/__init__.py @@ -1,10 +1,8 @@ -from . import ( - data, - descriptor, - entrypoints, - fit, - utils, -) +from . import data +from . import descriptor +from . import entrypoints +from . import fit +from . import utils __all__ = [ "data", diff --git a/deepmd/nvnmd/descriptor/se_a.py b/deepmd/nvnmd/descriptor/se_a.py index a18d8b85c9..ba8fb312aa 100644 --- a/deepmd/nvnmd/descriptor/se_a.py +++ b/deepmd/nvnmd/descriptor/se_a.py @@ -2,26 +2,16 @@ import numpy as np -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf # -from deepmd.nvnmd.utils.config import ( - nvnmd_cfg, -) -from deepmd.nvnmd.utils.weight import ( - get_normalize, -) -from deepmd.utils.graph import ( - get_tensor_by_name_from_graph, -) -from deepmd.utils.network import ( - embedding_net, -) +from deepmd.nvnmd.utils.config import nvnmd_cfg +from deepmd.nvnmd.utils.weight import get_normalize +from deepmd.utils.graph import get_tensor_by_name_from_graph +from deepmd.utils.network import embedding_net log = logging.getLogger(__name__) diff --git a/deepmd/nvnmd/entrypoints/__init__.py b/deepmd/nvnmd/entrypoints/__init__.py index 6f737c710b..5c61662405 100644 --- a/deepmd/nvnmd/entrypoints/__init__.py +++ b/deepmd/nvnmd/entrypoints/__init__.py @@ -1,11 +1,5 @@ -from .freeze import ( - save_weight, -) -from .mapt import ( - MapTable, -) -from .wrap import ( - Wrap, -) +from .freeze import save_weight +from .mapt import MapTable +from .wrap import Wrap __all__ = ["save_weight", "MapTable", "Wrap"] diff --git a/deepmd/nvnmd/entrypoints/freeze.py b/deepmd/nvnmd/entrypoints/freeze.py index 019b2f3382..d15cad6e44 100644 --- a/deepmd/nvnmd/entrypoints/freeze.py +++ b/deepmd/nvnmd/entrypoints/freeze.py @@ -1,14 +1,8 @@ #!/usr/bin/env python3 -from deepmd.env import ( - tf, -) -from deepmd.nvnmd.utils.fio import ( - FioDic, -) -from deepmd.utils.graph import ( - get_tensor_by_name_from_graph, -) +from deepmd.env import tf +from deepmd.nvnmd.utils.fio import FioDic +from deepmd.utils.graph import get_tensor_by_name_from_graph def filter_tensorVariableList(tensorVariableList) -> dict: diff --git a/deepmd/nvnmd/entrypoints/mapt.py b/deepmd/nvnmd/entrypoints/mapt.py index 50664a9552..8ca097d40d 100644 --- a/deepmd/nvnmd/entrypoints/mapt.py +++ b/deepmd/nvnmd/entrypoints/mapt.py @@ -1,34 +1,18 @@ import logging -from typing import ( - Optional, -) +from typing import Optional import numpy as np -from deepmd.env import ( - op_module, - tf, -) -from deepmd.nvnmd.data.data import ( - jdata_deepmd_input, - jdata_sys, -) -from deepmd.nvnmd.utils.config import ( - nvnmd_cfg, -) -from deepmd.nvnmd.utils.fio import ( - FioDic, -) -from deepmd.nvnmd.utils.network import ( - get_sess, -) -from deepmd.nvnmd.utils.weight import ( - get_filter_weight, - get_normalize, -) -from deepmd.utils.sess import ( - run_sess, -) +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.nvnmd.data.data import jdata_deepmd_input +from deepmd.nvnmd.data.data import jdata_sys +from deepmd.nvnmd.utils.config import nvnmd_cfg +from deepmd.nvnmd.utils.fio import FioDic +from deepmd.nvnmd.utils.network import get_sess +from deepmd.nvnmd.utils.weight import get_filter_weight +from deepmd.nvnmd.utils.weight import get_normalize +from deepmd.utils.sess import run_sess log = logging.getLogger(__name__) diff --git a/deepmd/nvnmd/entrypoints/train.py b/deepmd/nvnmd/entrypoints/train.py index b311ea7819..2d9863dbfd 100644 --- a/deepmd/nvnmd/entrypoints/train.py +++ b/deepmd/nvnmd/entrypoints/train.py @@ -1,33 +1,15 @@ import logging import os -from typing import ( - Optional, -) +from typing import Optional -from deepmd.entrypoints.freeze import ( - freeze, -) -from deepmd.entrypoints.train import ( - train, -) -from deepmd.env import ( - tf, -) -from deepmd.nvnmd.data.data import ( - jdata_deepmd_input, -) -from deepmd.nvnmd.entrypoints.mapt import ( - mapt, -) -from deepmd.nvnmd.entrypoints.wrap import ( - wrap, -) -from deepmd.nvnmd.utils.config import ( - nvnmd_cfg, -) -from deepmd.nvnmd.utils.fio import ( - FioDic, -) +from deepmd.entrypoints.freeze import freeze +from deepmd.entrypoints.train import train +from deepmd.env import tf +from deepmd.nvnmd.data.data import jdata_deepmd_input +from deepmd.nvnmd.entrypoints.mapt import mapt +from deepmd.nvnmd.entrypoints.wrap import wrap +from deepmd.nvnmd.utils.config import nvnmd_cfg +from deepmd.nvnmd.utils.fio import FioDic log = logging.getLogger(__name__) diff --git a/deepmd/nvnmd/entrypoints/wrap.py b/deepmd/nvnmd/entrypoints/wrap.py index 4bf12803f2..e326de509c 100644 --- a/deepmd/nvnmd/entrypoints/wrap.py +++ b/deepmd/nvnmd/entrypoints/wrap.py @@ -1,37 +1,19 @@ import logging -from typing import ( - Optional, -) +from typing import Optional import numpy as np -from deepmd.env import ( - op_module, - tf, -) -from deepmd.nvnmd.data.data import ( - jdata_deepmd_input, - jdata_sys, -) -from deepmd.nvnmd.utils.config import ( - nvnmd_cfg, -) -from deepmd.nvnmd.utils.encode import ( - Encode, -) -from deepmd.nvnmd.utils.fio import ( - FioBin, - FioTxt, -) -from deepmd.nvnmd.utils.network import ( - get_sess, -) -from deepmd.nvnmd.utils.weight import ( - get_fitnet_weight, -) -from deepmd.utils.sess import ( - run_sess, -) +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.nvnmd.data.data import jdata_deepmd_input +from deepmd.nvnmd.data.data import jdata_sys +from deepmd.nvnmd.utils.config import nvnmd_cfg +from deepmd.nvnmd.utils.encode import Encode +from deepmd.nvnmd.utils.fio import FioBin +from deepmd.nvnmd.utils.fio import FioTxt +from deepmd.nvnmd.utils.network import get_sess +from deepmd.nvnmd.utils.weight import get_fitnet_weight +from deepmd.utils.sess import run_sess log = logging.getLogger(__name__) diff --git a/deepmd/nvnmd/fit/ener.py b/deepmd/nvnmd/fit/ener.py index 9a250af82d..8a2cc69c8e 100644 --- a/deepmd/nvnmd/fit/ener.py +++ b/deepmd/nvnmd/fit/ener.py @@ -1,10 +1,6 @@ -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - tf, -) -from deepmd.nvnmd.utils.config import ( - nvnmd_cfg, -) +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.nvnmd.utils.config import nvnmd_cfg from deepmd.nvnmd.utils.network import one_layer as one_layer_nvnmd __all__ = [ diff --git a/deepmd/nvnmd/utils/__init__.py b/deepmd/nvnmd/utils/__init__.py index 4e201d917e..8e35d0e88a 100644 --- a/deepmd/nvnmd/utils/__init__.py +++ b/deepmd/nvnmd/utils/__init__.py @@ -1,27 +1,13 @@ -from .argcheck import ( - nvnmd_args, -) -from .config import ( - nvnmd_cfg, -) -from .encode import ( - Encode, -) -from .fio import ( - FioBin, - FioDic, - FioTxt, -) -from .network import ( - one_layer, -) -from .op import ( - map_nvnmd, -) -from .weight import ( - get_filter_weight, - get_fitnet_weight, -) +from .argcheck import nvnmd_args +from .config import nvnmd_cfg +from .encode import Encode +from .fio import FioBin +from .fio import FioDic +from .fio import FioTxt +from .network import one_layer +from .op import map_nvnmd +from .weight import get_filter_weight +from .weight import get_fitnet_weight __all__ = [ "nvnmd_args", diff --git a/deepmd/nvnmd/utils/argcheck.py b/deepmd/nvnmd/utils/argcheck.py index a53dae0d5a..e91e135706 100644 --- a/deepmd/nvnmd/utils/argcheck.py +++ b/deepmd/nvnmd/utils/argcheck.py @@ -1,6 +1,4 @@ -from dargs import ( - Argument, -) +from dargs import Argument def nvnmd_args(): diff --git a/deepmd/nvnmd/utils/config.py b/deepmd/nvnmd/utils/config.py index 9d756f8ef1..32b885d7ec 100644 --- a/deepmd/nvnmd/utils/config.py +++ b/deepmd/nvnmd/utils/config.py @@ -2,19 +2,13 @@ import numpy as np -from deepmd.nvnmd.data.data import ( - NVNMD_CITATION, - NVNMD_WELCOME, - jdata_config, - jdata_configs, - jdata_deepmd_input, -) -from deepmd.nvnmd.utils.fio import ( - FioDic, -) -from deepmd.nvnmd.utils.op import ( - r2s, -) +from deepmd.nvnmd.data.data import NVNMD_CITATION +from deepmd.nvnmd.data.data import NVNMD_WELCOME +from deepmd.nvnmd.data.data import jdata_config +from deepmd.nvnmd.data.data import jdata_configs +from deepmd.nvnmd.data.data import jdata_deepmd_input +from deepmd.nvnmd.utils.fio import FioDic +from deepmd.nvnmd.utils.op import r2s log = logging.getLogger(__name__) diff --git a/deepmd/nvnmd/utils/encode.py b/deepmd/nvnmd/utils/encode.py index 75cd629847..905fa638c5 100644 --- a/deepmd/nvnmd/utils/encode.py +++ b/deepmd/nvnmd/utils/encode.py @@ -2,9 +2,7 @@ import numpy as np -from deepmd.nvnmd.data.data import ( - jdata_sys, -) +from deepmd.nvnmd.data.data import jdata_sys log = logging.getLogger(__name__) diff --git a/deepmd/nvnmd/utils/fio.py b/deepmd/nvnmd/utils/fio.py index 8493bfd15d..04420a84c0 100644 --- a/deepmd/nvnmd/utils/fio.py +++ b/deepmd/nvnmd/utils/fio.py @@ -2,9 +2,7 @@ import logging import os import struct -from typing import ( - List, -) +from typing import List import numpy as np diff --git a/deepmd/nvnmd/utils/network.py b/deepmd/nvnmd/utils/network.py index cf727b3eec..9dba82ea7b 100644 --- a/deepmd/nvnmd/utils/network.py +++ b/deepmd/nvnmd/utils/network.py @@ -2,20 +2,12 @@ import numpy as np -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) -from deepmd.nvnmd.utils.config import ( - nvnmd_cfg, -) -from deepmd.nvnmd.utils.weight import ( - get_constant_initializer, -) -from deepmd.utils.network import ( - variable_summaries, -) +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.nvnmd.utils.config import nvnmd_cfg +from deepmd.nvnmd.utils.weight import get_constant_initializer +from deepmd.utils.network import variable_summaries log = logging.getLogger(__name__) diff --git a/deepmd/nvnmd/utils/weight.py b/deepmd/nvnmd/utils/weight.py index 77208d0d0a..b9a880a434 100644 --- a/deepmd/nvnmd/utils/weight.py +++ b/deepmd/nvnmd/utils/weight.py @@ -1,8 +1,6 @@ import logging -from deepmd.env import ( - tf, -) +from deepmd.env import tf log = logging.getLogger(__name__) diff --git a/deepmd/op/__init__.py b/deepmd/op/__init__.py index cf7b8a90ea..eac431c247 100644 --- a/deepmd/op/__init__.py +++ b/deepmd/op/__init__.py @@ -2,9 +2,7 @@ import importlib import logging -from pathlib import ( - Path, -) +from pathlib import Path NOT_LOADABLE = ("__init__.py",) PACKAGE_BASE = "deepmd.op" diff --git a/deepmd/train/run_options.py b/deepmd/train/run_options.py index e62ee7ef63..6c859919b1 100644 --- a/deepmd/train/run_options.py +++ b/deepmd/train/run_options.py @@ -2,27 +2,17 @@ import logging import os -from pathlib import ( - Path, -) -from typing import ( - TYPE_CHECKING, - List, - Optional, -) - -from deepmd.cluster import ( - get_resource, -) -from deepmd.env import ( - GLOBAL_CONFIG, - get_tf_default_nthreads, - global_float_prec, - tf, -) -from deepmd.loggers import ( - set_log_handles, -) +from pathlib import Path +from typing import TYPE_CHECKING +from typing import List +from typing import Optional + +from deepmd.cluster import get_resource +from deepmd.env import GLOBAL_CONFIG +from deepmd.env import get_tf_default_nthreads +from deepmd.env import global_float_prec +from deepmd.env import tf +from deepmd.loggers import set_log_handles if TYPE_CHECKING: import horovod.tensorflow as HVD diff --git a/deepmd/utils/__init__.py b/deepmd/utils/__init__.py index e7b79e1f28..75b8b25b51 100644 --- a/deepmd/utils/__init__.py +++ b/deepmd/utils/__init__.py @@ -1,20 +1,10 @@ # -from .data import ( - DeepmdData, -) -from .data_system import ( - DeepmdDataSystem, -) -from .learning_rate import ( - LearningRateExp, -) -from .pair_tab import ( - PairTab, -) -from .plugin import ( - Plugin, - PluginVariant, -) +from .data import DeepmdData +from .data_system import DeepmdDataSystem +from .learning_rate import LearningRateExp +from .pair_tab import PairTab +from .plugin import Plugin +from .plugin import PluginVariant __all__ = [ "DeepmdData", diff --git a/deepmd/utils/argcheck.py b/deepmd/utils/argcheck.py index 1fe00b4f43..370a67361f 100644 --- a/deepmd/utils/argcheck.py +++ b/deepmd/utils/argcheck.py @@ -1,28 +1,18 @@ import json import logging -from typing import ( - Callable, - List, - Optional, -) - -from dargs import ( - Argument, - ArgumentEncoder, - Variant, - dargs, -) - -from deepmd.common import ( - ACTIVATION_FN_DICT, - PRECISION_DICT, -) -from deepmd.nvnmd.utils.argcheck import ( - nvnmd_args, -) -from deepmd.utils.plugin import ( - Plugin, -) +from typing import Callable +from typing import List +from typing import Optional + +from dargs import Argument +from dargs import ArgumentEncoder +from dargs import Variant +from dargs import dargs + +from deepmd.common import ACTIVATION_FN_DICT +from deepmd.common import PRECISION_DICT +from deepmd.nvnmd.utils.argcheck import nvnmd_args +from deepmd.utils.plugin import Plugin log = logging.getLogger(__name__) diff --git a/deepmd/utils/compat.py b/deepmd/utils/compat.py index 4ec47b53a1..287a835b91 100644 --- a/deepmd/utils/compat.py +++ b/deepmd/utils/compat.py @@ -2,22 +2,16 @@ import json import warnings -from pathlib import ( - Path, -) -from typing import ( - Any, - Dict, - Optional, - Sequence, - Union, -) +from pathlib import Path +from typing import Any +from typing import Dict +from typing import Optional +from typing import Sequence +from typing import Union import numpy as np -from deepmd.common import ( - j_must_have, -) +from deepmd.common import j_must_have def convert_input_v0_v1( diff --git a/deepmd/utils/convert.py b/deepmd/utils/convert.py index 4948a8e70f..2fe55e2581 100644 --- a/deepmd/utils/convert.py +++ b/deepmd/utils/convert.py @@ -1,13 +1,9 @@ import os import textwrap -from google.protobuf import ( - text_format, -) +from google.protobuf import text_format -from deepmd.env import ( - tf, -) +from deepmd.env import tf def detect_model_version(input_model: str): diff --git a/deepmd/utils/data_system.py b/deepmd/utils/data_system.py index f7bc1c500d..dc1fb25464 100644 --- a/deepmd/utils/data_system.py +++ b/deepmd/utils/data_system.py @@ -1,20 +1,14 @@ import collections import logging import warnings -from typing import ( - List, - Optional, -) +from typing import List +from typing import Optional import numpy as np -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION from deepmd.utils import random as dp_random -from deepmd.utils.data import ( - DeepmdData, -) +from deepmd.utils.data import DeepmdData log = logging.getLogger(__name__) diff --git a/deepmd/utils/finetune.py b/deepmd/utils/finetune.py index 9b39d68b30..0107a09d17 100644 --- a/deepmd/utils/finetune.py +++ b/deepmd/utils/finetune.py @@ -1,16 +1,10 @@ import json import logging -from typing import ( - Any, - Dict, -) +from typing import Any +from typing import Dict -from deepmd.utils.errors import ( - GraphWithoutTensorError, -) -from deepmd.utils.graph import ( - get_tensor_by_name, -) +from deepmd.utils.errors import GraphWithoutTensorError +from deepmd.utils.graph import get_tensor_by_name log = logging.getLogger(__name__) diff --git a/deepmd/utils/graph.py b/deepmd/utils/graph.py index 71858039b1..9c46c28dc0 100644 --- a/deepmd/utils/graph.py +++ b/deepmd/utils/graph.py @@ -1,24 +1,16 @@ import re -from typing import ( - Dict, - Tuple, -) +from typing import Dict +from typing import Tuple import numpy as np -from deepmd.env import ( - ATTENTION_LAYER_PATTERN, - EMBEDDING_NET_PATTERN, - FITTING_NET_PATTERN, - TYPE_EMBEDDING_PATTERN, - tf, -) -from deepmd.utils.errors import ( - GraphWithoutTensorError, -) -from deepmd.utils.sess import ( - run_sess, -) +from deepmd.env import ATTENTION_LAYER_PATTERN +from deepmd.env import EMBEDDING_NET_PATTERN +from deepmd.env import FITTING_NET_PATTERN +from deepmd.env import TYPE_EMBEDDING_PATTERN +from deepmd.env import tf +from deepmd.utils.errors import GraphWithoutTensorError +from deepmd.utils.sess import run_sess # TODO (JZ): I think in this file we can merge some duplicated lines into one method... diff --git a/deepmd/utils/multi_init.py b/deepmd/utils/multi_init.py index d5496b47ea..08f1865c91 100644 --- a/deepmd/utils/multi_init.py +++ b/deepmd/utils/multi_init.py @@ -1,16 +1,10 @@ import json import logging -from typing import ( - Any, - Dict, -) +from typing import Any +from typing import Dict -from deepmd.utils.errors import ( - GraphWithoutTensorError, -) -from deepmd.utils.graph import ( - get_tensor_by_name, -) +from deepmd.utils.errors import GraphWithoutTensorError +from deepmd.utils.graph import get_tensor_by_name log = logging.getLogger(__name__) diff --git a/deepmd/utils/pair_tab.py b/deepmd/utils/pair_tab.py index b8642c7009..13dcef438a 100644 --- a/deepmd/utils/pair_tab.py +++ b/deepmd/utils/pair_tab.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 -from typing import ( - Tuple, -) +from typing import Tuple import numpy as np -from scipy.interpolate import ( - CubicSpline, -) +from scipy.interpolate import CubicSpline class PairTab: diff --git a/deepmd/utils/parallel_op.py b/deepmd/utils/parallel_op.py index db27d5604e..1453e9377f 100644 --- a/deepmd/utils/parallel_op.py +++ b/deepmd/utils/parallel_op.py @@ -1,18 +1,12 @@ -from typing import ( - Any, - Callable, - Dict, - Generator, - Optional, - Tuple, -) +from typing import Any +from typing import Callable +from typing import Dict +from typing import Generator +from typing import Optional +from typing import Tuple -from deepmd.env import ( - tf, -) -from deepmd.utils.sess import ( - run_sess, -) +from deepmd.env import tf +from deepmd.utils.sess import run_sess class ParallelOp: diff --git a/deepmd/utils/path.py b/deepmd/utils/path.py index 454eed3d2b..ba1f1e87a2 100644 --- a/deepmd/utils/path.py +++ b/deepmd/utils/path.py @@ -1,24 +1,14 @@ import os -from abc import ( - ABC, - abstractmethod, -) -from functools import ( - lru_cache, -) -from pathlib import ( - Path, -) -from typing import ( - List, - Optional, -) +from abc import ABC +from abc import abstractmethod +from functools import lru_cache +from pathlib import Path +from typing import List +from typing import Optional import h5py import numpy as np -from wcmatch.glob import ( - globfilter, -) +from wcmatch.glob import globfilter class DPPath(ABC): diff --git a/deepmd/utils/plugin.py b/deepmd/utils/plugin.py index 66b4569029..c49328ef2b 100644 --- a/deepmd/utils/plugin.py +++ b/deepmd/utils/plugin.py @@ -1,12 +1,8 @@ """Base of plugin systems.""" # copied from https://github.com/deepmodeling/dpdata/blob/a3e76d75de53f6076254de82d18605a010dc3b00/dpdata/plugin.py -from abc import ( - ABCMeta, -) -from typing import ( - Callable, -) +from abc import ABCMeta +from typing import Callable class Plugin: diff --git a/deepmd/utils/random.py b/deepmd/utils/random.py index 57d0af4d55..0632d6bc64 100644 --- a/deepmd/utils/random.py +++ b/deepmd/utils/random.py @@ -1,6 +1,4 @@ -from typing import ( - Optional, -) +from typing import Optional import numpy as np diff --git a/deepmd/utils/sess.py b/deepmd/utils/sess.py index 67bbd36878..53e0abd850 100644 --- a/deepmd/utils/sess.py +++ b/deepmd/utils/sess.py @@ -1,11 +1,7 @@ import os -from deepmd.env import ( - tf, -) -from deepmd.utils.errors import ( - OutOfMemoryError, -) +from deepmd.env import tf +from deepmd.utils.errors import OutOfMemoryError def run_sess(sess: tf.Session, *args, **kwargs): diff --git a/deepmd/utils/spin.py b/deepmd/utils/spin.py index 38801fe3b9..67969869a9 100644 --- a/deepmd/utils/spin.py +++ b/deepmd/utils/spin.py @@ -1,11 +1,7 @@ -from typing import ( - List, -) +from typing import List -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - tf, -) +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import tf class Spin: diff --git a/deepmd/utils/tabulate.py b/deepmd/utils/tabulate.py index aa842178f7..a8ce9fd9d4 100644 --- a/deepmd/utils/tabulate.py +++ b/deepmd/utils/tabulate.py @@ -1,34 +1,20 @@ import logging -from functools import ( - lru_cache, -) -from typing import ( - Callable, - Dict, - List, - Tuple, -) +from functools import lru_cache +from typing import Callable +from typing import Dict +from typing import List +from typing import Tuple import numpy as np -from scipy.special import ( - comb, -) +from scipy.special import comb import deepmd -from deepmd.common import ( - ACTIVATION_FN_DICT, -) -from deepmd.descriptor import ( - Descriptor, -) -from deepmd.env import ( - op_module, - tf, -) -from deepmd.utils.graph import ( - get_embedding_net_nodes_from_graph_def, - get_tensor_by_name_from_graph, -) +from deepmd.common import ACTIVATION_FN_DICT +from deepmd.descriptor import Descriptor +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.utils.graph import get_embedding_net_nodes_from_graph_def +from deepmd.utils.graph import get_tensor_by_name_from_graph log = logging.getLogger(__name__) diff --git a/deepmd/utils/weight_avg.py b/deepmd/utils/weight_avg.py index b46e3a0d37..728094e563 100644 --- a/deepmd/utils/weight_avg.py +++ b/deepmd/utils/weight_avg.py @@ -1,11 +1,7 @@ -from collections import ( - defaultdict, -) -from typing import ( - Dict, - List, - Tuple, -) +from collections import defaultdict +from typing import Dict +from typing import List +from typing import Tuple import numpy as np diff --git a/doc/conf.py b/doc/conf.py index 5e034b36c1..519ce94f1c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -12,17 +12,11 @@ # import os import sys -from datetime import ( - date, -) +from datetime import date -from deepmd.common import ( - ACTIVATION_FN_DICT, - PRECISION_DICT, -) -from deepmd.utils.argcheck import ( - list_to_doc, -) +from deepmd.common import ACTIVATION_FN_DICT +from deepmd.common import PRECISION_DICT +from deepmd.utils.argcheck import list_to_doc sys.path.append(os.path.dirname(__file__)) import sphinx_contrib_exhale_multiproject # noqa: F401 @@ -127,9 +121,7 @@ def classify_index_TS(): def run_apidoc(_): import sys - from sphinx.ext.apidoc import ( - main, - ) + from sphinx.ext.apidoc import main sys.path.append(os.path.join(os.path.dirname(__file__), "..")) cur_dir = os.path.abspath(os.path.dirname(__file__)) diff --git a/doc/install/install-tf.1.14-gpu.md b/doc/install/install-tf.1.14-gpu.md index 4e9fcaf7fc..46d676d1b9 100644 --- a/doc/install/install-tf.1.14-gpu.md +++ b/doc/install/install-tf.1.14-gpu.md @@ -72,21 +72,21 @@ Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: Not configuring the WORKSPACE for Android builds. Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See .bazelrc for more details. - --config=mkl # Build with MKL support. - --config=monolithic # Config for mostly static monolithic build. - --config=gdr # Build with GDR support. - --config=verbs # Build with libverbs support. - --config=ngraph # Build with Intel nGraph support. - --config=numa # Build with NUMA support. - --config=dynamic_kernels # (Experimental) Build kernels into separate shared objects. - --config=v2 # Build TensorFlow 2.x instead of 1.x. + --config=mkl # Build with MKL support. + --config=monolithic # Config for mostly static monolithic build. + --config=gdr # Build with GDR support. + --config=verbs # Build with libverbs support. + --config=ngraph # Build with Intel nGraph support. + --config=numa # Build with NUMA support. + --config=dynamic_kernels # (Experimental) Build kernels into separate shared objects. + --config=v2 # Build TensorFlow 2.x instead of 1.x. Preconfigured Bazel build configs to DISABLE default on features: - --config=noaws # Disable AWS S3 filesystem support. - --config=nogcp # Disable GCP support. - --config=nohdfs # Disable HDFS support. - --config=noignite # Disable Apache Ignite support. - --config=nokafka # Disable Apache Kafka support. - --config=nonccl # Disable NVIDIA NCCL support. + --config=noaws # Disable AWS S3 filesystem support. + --config=nogcp # Disable GCP support. + --config=nohdfs # Disable HDFS support. + --config=noignite # Disable Apache Ignite support. + --config=nokafka # Disable Apache Kafka support. + --config=nonccl # Disable NVIDIA NCCL support. Configuration finished ``` diff --git a/doc/logo.md b/doc/logo.md index 420f378336..67c303f651 100644 --- a/doc/logo.md +++ b/doc/logo.md @@ -1,5 +1,5 @@ -# Logo - -DeePMD-kit logo - -The logo of DeePMD-kit is a beaver. Beavers were widely distributed in Europe and Asia but became nearly extinct due to hunting. Listed as a first-class state-protected animal in China, the population of beavers in China is less than the giant pandas. We hope that users of DeePMD-kit can enhance the awareness to protect beavers. +# Logo + +DeePMD-kit logo + +The logo of DeePMD-kit is a beaver. Beavers were widely distributed in Europe and Asia but became nearly extinct due to hunting. Listed as a first-class state-protected animal in China, the population of beavers in China is less than the giant pandas. We hope that users of DeePMD-kit can enhance the awareness to protect beavers. diff --git a/doc/model/dplr.md b/doc/model/dplr.md index 27bfadcf00..46ff1ac25c 100644 --- a/doc/model/dplr.md +++ b/doc/model/dplr.md @@ -15,20 +15,20 @@ $deepmd_source_dir/examples/water/dplr/train/ It is noted that **the tutorial dataset is not enough for training a productive model**. Two settings make the training input script different from an energy training input: ```json - "fitting_net": { - "type": "dipole", - "dipole_type": [0], - "neuron": [128, 128, 128], - "seed": 1 - }, + "fitting_net": { + "type": "dipole", + "dipole_type": [0], + "neuron": [128, 128, 128], + "seed": 1 + }, ``` The type of fitting is set to {ref}`dipole `. The dipole is associated with type 0 atoms (oxygens), by the setting `"dipole_type": [0]`. What we trained is the displacement of the WC from the corresponding oxygen atom. It shares the same training input as the atomic dipole because both are 3-dimensional vectors defined on atoms. The loss section is provided as follows ```json "loss": { - "type": "tensor", - "pref": 0.0, - "pref_atomic": 1.0 + "type": "tensor", + "pref": 0.0, + "pref_atomic": 1.0 }, ``` so that the atomic dipole is trained as labels. Note that the NumPy compressed file `atomic_dipole.npy` should be provided in each dataset. @@ -128,8 +128,8 @@ Type 1 and 2 (O and H) are `real_atom`s, while type 3 (WCs) are `virtual_atom`s. # kspace_style "pppm/dplr" should be used. in addition the # gewald(1/distance) should be set the same as that used in # training. Currently only ik differentiation is supported. -kspace_style pppm/dplr 1e-5 -kspace_modify gewald ${BETA} diff ik mesh ${KMESH} ${KMESH} ${KMESH} +kspace_style pppm/dplr 1e-5 +kspace_modify gewald ${BETA} diff ik mesh ${KMESH} ${KMESH} ${KMESH} ``` The long-range part is calculated by the `kspace` support of LAMMPS. The `kspace_style` `pppm/dplr` is required. The spread parameter set by variable `BETA` should be set the same as that used in training. The `KMESH` should be set dense enough so the long-range calculation is converged. @@ -139,18 +139,18 @@ The long-range part is calculated by the `kspace` support of LAMMPS. The `kspace # atoms. "type_associate" associates the real atom type its # corresponding virtual atom type. "bond_type" gives the type of the # bond between the real and virtual atoms. -fix 0 all dplr model ener.pb type_associate 1 3 bond_type 1 -fix_modify 0 virial yes +fix 0 all dplr model ener.pb type_associate 1 3 bond_type 1 +fix_modify 0 virial yes ``` The fix command `dplr` calculates the position of WCs by the DW model and back-propagates the long-range interaction on virtual atoms to real toms. At this time, the training parameter {ref}`type_map ` will be mapped to LAMMPS atom types. ```lammps # compute the temperature of real atoms, excluding virtual atom contribution -compute real_temp real_atom temp -compute real_press all pressure real_temp -fix 1 real_atom nvt temp ${TEMP} ${TEMP} ${TAU_T} -fix_modify 1 temp real_temp +compute real_temp real_atom temp +compute real_press all pressure real_temp +fix 1 real_atom nvt temp ${TEMP} ${TEMP} ${TAU_T} +fix_modify 1 temp real_temp ``` The temperature of the system should be computed from the real atoms. The kinetic contribution in the pressure tensor is also computed from the real atoms. The thermostat is applied to only real atoms. The computed temperature and pressure of real atoms can be accessed by, e.g. ```lammps diff --git a/doc/model/overall.md b/doc/model/overall.md index 3d4052e464..e13971afc2 100644 --- a/doc/model/overall.md +++ b/doc/model/overall.md @@ -3,7 +3,7 @@ A model has two parts, a descriptor that maps atomic configuration to a set of symmetry invariant features, and a fitting net that takes descriptor as input and predicts the atomic contribution to the target physical property. It's defined in the {ref}`model ` section of the `input.json`, for example, ```json "model": { - "type_map": ["O", "H"], + "type_map": ["O", "H"], "descriptor" :{ "...": "..." }, diff --git a/doc/model/train-energy-spin.md b/doc/model/train-energy-spin.md index d155ec977d..19af54d3d0 100644 --- a/doc/model/train-energy-spin.md +++ b/doc/model/train-energy-spin.md @@ -36,15 +36,15 @@ pref_fr(t) = start_pref_fr * ( lr(t) / start_lr ) + limit_pref_fr * ( 1 - lr(t) The {ref}`loss ` section in the `input.json` is ```json "loss" :{ - "type": "ener_spin", - "start_pref_e": 0.02, - "limit_pref_e": 1, - "start_pref_fr": 1000, - "limit_pref_fr": 1.0, - "start_pref_fm": 10000, - "limit_pref_fm": 10.0, - "start_pref_v": 0, - "limit_pref_v": 0, + "type": "ener_spin", + "start_pref_e": 0.02, + "limit_pref_e": 1, + "start_pref_fr": 1000, + "limit_pref_fr": 1.0, + "start_pref_fm": 10000, + "limit_pref_fm": 10.0, + "start_pref_v": 0, + "limit_pref_v": 0, }, ``` The options {ref}`start_pref_e `, {ref}`limit_pref_e `, {ref}`start_pref_fr `, {ref}`limit_pref_fm `, {ref}`start_pref_v ` and {ref}`limit_pref_v ` determine the start and limit prefactors of energy, atomic force, magnatic force and virial, respectively. diff --git a/doc/model/train-energy.md b/doc/model/train-energy.md index af3e4969b3..5d57e5f631 100644 --- a/doc/model/train-energy.md +++ b/doc/model/train-energy.md @@ -6,11 +6,11 @@ In this section, we will take `$deepmd_source_dir/examples/water/se_e2_a/input.j The construction of the fitting net is given by section {ref}`fitting_net ` ```json - "fitting_net" : { - "neuron": [240, 240, 240], - "resnet_dt": true, - "seed": 1 - }, + "fitting_net" : { + "neuron": [240, 240, 240], + "resnet_dt": true, + "seed": 1 + }, ``` * {ref}`neuron ` specifies the size of the fitting net. If two neighboring layers are of the same size, then a [ResNet architecture](https://arxiv.org/abs/1512.03385) is built between them. * If the option {ref}`resnet_dt ` is set to `true`, then a timestep is used in the ResNet. @@ -34,12 +34,12 @@ pref_f(t) = start_pref_f * ( lr(t) / start_lr ) + limit_pref_f * ( 1 - lr(t) / s The {ref}`loss ` section in the `input.json` is ```json "loss" : { - "start_pref_e": 0.02, - "limit_pref_e": 1, - "start_pref_f": 1000, - "limit_pref_f": 1, - "start_pref_v": 0, - "limit_pref_v": 0 + "start_pref_e": 0.02, + "limit_pref_e": 1, + "start_pref_f": 1000, + "limit_pref_f": 1, + "start_pref_v": 0, + "limit_pref_v": 0 } ``` The options {ref}`start_pref_e `, {ref}`limit_pref_e `, {ref}`start_pref_f `, {ref}`limit_pref_f `, {ref}`start_pref_v ` and {ref}`limit_pref_v ` determine the start and limit prefactors of energy, force and virial, respectively. diff --git a/doc/model/train-fitting-dos.md b/doc/model/train-fitting-dos.md index bbe5b50690..1a9800dfed 100644 --- a/doc/model/train-fitting-dos.md +++ b/doc/model/train-fitting-dos.md @@ -21,15 +21,15 @@ The {ref}`fitting_net ` section tells DP which fitting net to The JSON of `dos` type should be provided like ```json - "fitting_net" : { - "type": "dos", - "numb_dos": 250, - "sel_type": [0], - "neuron": [120,120,120], - "resnet_dt": true, - "fparam": 0, - "seed": 1, - }, + "fitting_net" : { + "type": "dos", + "numb_dos": 250, + "sel_type": [0], + "neuron": [120,120,120], + "resnet_dt": true, + "fparam": 0, + "seed": 1, + }, ``` - `type` specifies which type of fitting net should be used. It should be `dos`. @@ -49,17 +49,17 @@ loss = pref * global_loss + pref_atomic * atomic_loss The loss section should be provided like ```json - "loss" : { - "type": "dos", - "start_pref_dos": 0.0, - "limit_pref_dos": 0.0, - "start_pref_cdf": 0.0, - "limit_pref_cdf": 0.0, - "start_pref_ados": 1.0, - "limit_pref_ados": 1.0, - "start_pref_acdf": 0.0, - "limit_pref_acdf": 0.0 - }, + "loss" : { + "type": "dos", + "start_pref_dos": 0.0, + "limit_pref_dos": 0.0, + "start_pref_cdf": 0.0, + "limit_pref_cdf": 0.0, + "start_pref_ados": 1.0, + "limit_pref_ados": 1.0, + "start_pref_acdf": 0.0, + "limit_pref_acdf": 0.0 + }, ``` - {ref}`type ` should be written as `dos` as a distinction from `ener` mode. diff --git a/doc/model/train-fitting-tensor.md b/doc/model/train-fitting-tensor.md index d7c06a25ed..c941ef93ee 100644 --- a/doc/model/train-fitting-tensor.md +++ b/doc/model/train-fitting-tensor.md @@ -1,123 +1,123 @@ -# Fit `tensor` like `Dipole` and `Polarizability` - -Unlike `energy`, which is a scalar, one may want to fit some high dimensional physical quantity, like `dipole` (vector) and `polarizability` (matrix, shorted as `polar`). Deep Potential has provided different APIs to do this. In this example, we will show you how to train a model to fit a water system. A complete training input script of the examples can be found in - -```bash -$deepmd_source_dir/examples/water_tensor/dipole/dipole_input.json -$deepmd_source_dir/examples/water_tensor/polar/polar_input.json -``` - -The training and validation data are also provided our examples. But note that **the data provided along with the examples are of limited amount, and should not be used to train a production model.** - -Similar to the `input.json` used in `ener` mode, training JSON is also divided into {ref}`model `, {ref}`learning_rate `, {ref}`loss ` and {ref}`training `. Most keywords remain the same as `ener` mode, and their meaning can be found [here](train-se-e2-a.md). To fit a tensor, one needs to modify {ref}`model/fitting_net ` and {ref}`loss `. - -## The fitting Network - -The {ref}`fitting_net ` section tells DP which fitting net to use. - -The JSON of `dipole` type should be provided like - -```json - "fitting_net" : { - "type": "dipole", - "sel_type": [0], - "neuron": [100,100,100], - "resnet_dt": true, - "seed": 1, - }, -``` - -The JSON of `polar` type should be provided like - -```json - "fitting_net" : { - "type": "polar", - "sel_type": [0], - "neuron": [100,100,100], - "resnet_dt": true, - "seed": 1, - }, -``` - -- `type` specifies which type of fitting net should be used. It should be either `dipole` or `polar`. Note that `global_polar` mode in version 1.x is already **deprecated** and is merged into `polar`. To specify whether a system is global or atomic, please see [here](train-se-e2-a.md). -- `sel_type` is a list specifying which type of atoms have the quantity you want to fit. For example, in the water system, `sel_type` is `[0]` since `0` represents atom `O`. If left unset, all types of atoms will be fitted. -- The rest arguments have the same meaning as they do in `ener` mode. - -## Loss - -DP supports a combinational training of the global system (only a global `tensor` label, i.e. dipole or polar, is provided in a frame) and atomic system (labels for **each** atom included in `sel_type` are provided). In a global system, each frame has just **one** `tensor` label. For example, when fitting `polar`, each frame will just provide a `1 x 9` vector which gives the elements of the polarizability tensor of that frame in order XX, XY, XZ, YX, YY, YZ, XZ, ZY, ZZ. By contrast, in an atomic system, each atom in `sel_type` has a `tensor` label. For example, when fitting a dipole, each frame will provide a `#sel_atom x 3` matrices, where `#sel_atom` is the number of atoms whose type are in `sel_type`. - -The {ref}`loss ` section tells DP the weight of these two kinds of loss, i.e. - -```python -loss = pref * global_loss + pref_atomic * atomic_loss -``` - -The loss section should be provided like - -```json - "loss" : { - "type": "tensor", - "pref": 1.0, - "pref_atomic": 1.0 - }, -``` - -- {ref}`type ` should be written as `tensor` as a distinction from `ener` mode. -- {ref}`pref ` and {ref}`pref_atomic ` respectively specify the weight of global loss and atomic loss. It can not be left unset. If set to 0, the corresponding label will NOT be included in the training process. - -## Training Data Preparation - -In tensor mode, the identification of the label's type (global or atomic) is derived from the file name. The global label should be named `dipole.npy/raw` or `polarizability.npy/raw`, while the atomic label should be named `atomic_dipole.npy/raw` or `atomic_polarizability.npy/raw`. If wrongly named, DP will report an error - -```bash -ValueError: cannot reshape array of size xxx into shape (xx,xx). This error may occur when your label mismatch it's name, i.e. you might store global tensor in `atomic_tensor.npy` or atomic tensor in `tensor.npy`. -``` - -In this case, please check the file name of the label. - -## Train the Model - -The training command is the same as `ener` mode, i.e. - -```bash -dp train input.json -``` - -The detailed loss can be found in `lcurve.out`: - -``` -# step rmse_val rmse_trn rmse_lc_val rmse_lc_trn rmse_gl_val rmse_gl_trn lr - 0 8.34e+00 8.26e+00 8.34e+00 8.26e+00 0.00e+00 0.00e+00 1.0e-02 - 100 3.51e-02 8.55e-02 0.00e+00 8.55e-02 4.38e-03 0.00e+00 5.0e-03 - 200 4.77e-02 5.61e-02 0.00e+00 5.61e-02 5.96e-03 0.00e+00 2.5e-03 - 300 5.68e-02 1.47e-02 0.00e+00 0.00e+00 7.10e-03 1.84e-03 1.3e-03 - 400 3.73e-02 3.48e-02 1.99e-02 0.00e+00 2.18e-03 4.35e-03 6.3e-04 - 500 2.77e-02 5.82e-02 1.08e-02 5.82e-02 2.11e-03 0.00e+00 3.2e-04 - 600 2.81e-02 5.43e-02 2.01e-02 0.00e+00 1.01e-03 6.79e-03 1.6e-04 - 700 2.97e-02 3.28e-02 2.03e-02 0.00e+00 1.17e-03 4.10e-03 7.9e-05 - 800 2.25e-02 6.19e-02 9.05e-03 0.00e+00 1.68e-03 7.74e-03 4.0e-05 - 900 3.18e-02 5.54e-02 9.93e-03 5.54e-02 2.74e-03 0.00e+00 2.0e-05 - 1000 2.63e-02 5.02e-02 1.02e-02 5.02e-02 2.01e-03 0.00e+00 1.0e-05 - 1100 3.27e-02 5.89e-02 2.13e-02 5.89e-02 1.43e-03 0.00e+00 5.0e-06 - 1200 2.85e-02 2.42e-02 2.85e-02 0.00e+00 0.00e+00 3.02e-03 2.5e-06 - 1300 3.47e-02 5.71e-02 1.07e-02 5.71e-02 3.00e-03 0.00e+00 1.3e-06 - 1400 3.13e-02 5.76e-02 3.13e-02 5.76e-02 0.00e+00 0.00e+00 6.3e-07 - 1500 3.34e-02 1.11e-02 2.09e-02 0.00e+00 1.57e-03 1.39e-03 3.2e-07 - 1600 3.11e-02 5.64e-02 3.11e-02 5.64e-02 0.00e+00 0.00e+00 1.6e-07 - 1700 2.97e-02 5.05e-02 2.97e-02 5.05e-02 0.00e+00 0.00e+00 7.9e-08 - 1800 2.64e-02 7.70e-02 1.09e-02 0.00e+00 1.94e-03 9.62e-03 4.0e-08 - 1900 3.28e-02 2.56e-02 3.28e-02 0.00e+00 0.00e+00 3.20e-03 2.0e-08 - 2000 2.59e-02 5.71e-02 1.03e-02 5.71e-02 1.94e-03 0.00e+00 1.0e-08 -``` - -One may notice that in each step, some of the local loss and global loss will be `0.0`. This is because our training data and validation data consist of the global system and atomic system, i.e. -``` - --training_data - >atomic_system - >global_system - --validation_data - >atomic_system - >global_system -``` -During training, at each step when the `lcurve.out` is printed, the system used for evaluating the training (validation) error may be either with only global or only atomic labels, thus the corresponding atomic or global errors are missing and are printed as zeros. +# Fit `tensor` like `Dipole` and `Polarizability` + +Unlike `energy`, which is a scalar, one may want to fit some high dimensional physical quantity, like `dipole` (vector) and `polarizability` (matrix, shorted as `polar`). Deep Potential has provided different APIs to do this. In this example, we will show you how to train a model to fit a water system. A complete training input script of the examples can be found in + +```bash +$deepmd_source_dir/examples/water_tensor/dipole/dipole_input.json +$deepmd_source_dir/examples/water_tensor/polar/polar_input.json +``` + +The training and validation data are also provided our examples. But note that **the data provided along with the examples are of limited amount, and should not be used to train a production model.** + +Similar to the `input.json` used in `ener` mode, training JSON is also divided into {ref}`model `, {ref}`learning_rate `, {ref}`loss ` and {ref}`training `. Most keywords remain the same as `ener` mode, and their meaning can be found [here](train-se-e2-a.md). To fit a tensor, one needs to modify {ref}`model/fitting_net ` and {ref}`loss `. + +## The fitting Network + +The {ref}`fitting_net ` section tells DP which fitting net to use. + +The JSON of `dipole` type should be provided like + +```json + "fitting_net" : { + "type": "dipole", + "sel_type": [0], + "neuron": [100,100,100], + "resnet_dt": true, + "seed": 1, + }, +``` + +The JSON of `polar` type should be provided like + +```json + "fitting_net" : { + "type": "polar", + "sel_type": [0], + "neuron": [100,100,100], + "resnet_dt": true, + "seed": 1, + }, +``` + +- `type` specifies which type of fitting net should be used. It should be either `dipole` or `polar`. Note that `global_polar` mode in version 1.x is already **deprecated** and is merged into `polar`. To specify whether a system is global or atomic, please see [here](train-se-e2-a.md). +- `sel_type` is a list specifying which type of atoms have the quantity you want to fit. For example, in the water system, `sel_type` is `[0]` since `0` represents atom `O`. If left unset, all types of atoms will be fitted. +- The rest arguments have the same meaning as they do in `ener` mode. + +## Loss + +DP supports a combinational training of the global system (only a global `tensor` label, i.e. dipole or polar, is provided in a frame) and atomic system (labels for **each** atom included in `sel_type` are provided). In a global system, each frame has just **one** `tensor` label. For example, when fitting `polar`, each frame will just provide a `1 x 9` vector which gives the elements of the polarizability tensor of that frame in order XX, XY, XZ, YX, YY, YZ, XZ, ZY, ZZ. By contrast, in an atomic system, each atom in `sel_type` has a `tensor` label. For example, when fitting a dipole, each frame will provide a `#sel_atom x 3` matrices, where `#sel_atom` is the number of atoms whose type are in `sel_type`. + +The {ref}`loss ` section tells DP the weight of these two kinds of loss, i.e. + +```python +loss = pref * global_loss + pref_atomic * atomic_loss +``` + +The loss section should be provided like + +```json + "loss" : { + "type": "tensor", + "pref": 1.0, + "pref_atomic": 1.0 + }, +``` + +- {ref}`type ` should be written as `tensor` as a distinction from `ener` mode. +- {ref}`pref ` and {ref}`pref_atomic ` respectively specify the weight of global loss and atomic loss. It can not be left unset. If set to 0, the corresponding label will NOT be included in the training process. + +## Training Data Preparation + +In tensor mode, the identification of the label's type (global or atomic) is derived from the file name. The global label should be named `dipole.npy/raw` or `polarizability.npy/raw`, while the atomic label should be named `atomic_dipole.npy/raw` or `atomic_polarizability.npy/raw`. If wrongly named, DP will report an error + +```bash +ValueError: cannot reshape array of size xxx into shape (xx,xx). This error may occur when your label mismatch it's name, i.e. you might store global tensor in `atomic_tensor.npy` or atomic tensor in `tensor.npy`. +``` + +In this case, please check the file name of the label. + +## Train the Model + +The training command is the same as `ener` mode, i.e. + +```bash +dp train input.json +``` + +The detailed loss can be found in `lcurve.out`: + +``` +# step rmse_val rmse_trn rmse_lc_val rmse_lc_trn rmse_gl_val rmse_gl_trn lr + 0 8.34e+00 8.26e+00 8.34e+00 8.26e+00 0.00e+00 0.00e+00 1.0e-02 + 100 3.51e-02 8.55e-02 0.00e+00 8.55e-02 4.38e-03 0.00e+00 5.0e-03 + 200 4.77e-02 5.61e-02 0.00e+00 5.61e-02 5.96e-03 0.00e+00 2.5e-03 + 300 5.68e-02 1.47e-02 0.00e+00 0.00e+00 7.10e-03 1.84e-03 1.3e-03 + 400 3.73e-02 3.48e-02 1.99e-02 0.00e+00 2.18e-03 4.35e-03 6.3e-04 + 500 2.77e-02 5.82e-02 1.08e-02 5.82e-02 2.11e-03 0.00e+00 3.2e-04 + 600 2.81e-02 5.43e-02 2.01e-02 0.00e+00 1.01e-03 6.79e-03 1.6e-04 + 700 2.97e-02 3.28e-02 2.03e-02 0.00e+00 1.17e-03 4.10e-03 7.9e-05 + 800 2.25e-02 6.19e-02 9.05e-03 0.00e+00 1.68e-03 7.74e-03 4.0e-05 + 900 3.18e-02 5.54e-02 9.93e-03 5.54e-02 2.74e-03 0.00e+00 2.0e-05 + 1000 2.63e-02 5.02e-02 1.02e-02 5.02e-02 2.01e-03 0.00e+00 1.0e-05 + 1100 3.27e-02 5.89e-02 2.13e-02 5.89e-02 1.43e-03 0.00e+00 5.0e-06 + 1200 2.85e-02 2.42e-02 2.85e-02 0.00e+00 0.00e+00 3.02e-03 2.5e-06 + 1300 3.47e-02 5.71e-02 1.07e-02 5.71e-02 3.00e-03 0.00e+00 1.3e-06 + 1400 3.13e-02 5.76e-02 3.13e-02 5.76e-02 0.00e+00 0.00e+00 6.3e-07 + 1500 3.34e-02 1.11e-02 2.09e-02 0.00e+00 1.57e-03 1.39e-03 3.2e-07 + 1600 3.11e-02 5.64e-02 3.11e-02 5.64e-02 0.00e+00 0.00e+00 1.6e-07 + 1700 2.97e-02 5.05e-02 2.97e-02 5.05e-02 0.00e+00 0.00e+00 7.9e-08 + 1800 2.64e-02 7.70e-02 1.09e-02 0.00e+00 1.94e-03 9.62e-03 4.0e-08 + 1900 3.28e-02 2.56e-02 3.28e-02 0.00e+00 0.00e+00 3.20e-03 2.0e-08 + 2000 2.59e-02 5.71e-02 1.03e-02 5.71e-02 1.94e-03 0.00e+00 1.0e-08 +``` + +One may notice that in each step, some of the local loss and global loss will be `0.0`. This is because our training data and validation data consist of the global system and atomic system, i.e. +``` + --training_data + >atomic_system + >global_system + --validation_data + >atomic_system + >global_system +``` +During training, at each step when the `lcurve.out` is printed, the system used for evaluating the training (validation) error may be either with only global or only atomic labels, thus the corresponding atomic or global errors are missing and are printed as zeros. diff --git a/doc/model/train-hybrid.md b/doc/model/train-hybrid.md index 37666668c7..65c52c6763 100644 --- a/doc/model/train-hybrid.md +++ b/doc/model/train-hybrid.md @@ -8,12 +8,12 @@ To use the descriptor in DeePMD-kit, one firstly set the {ref}`type `. An example of the descriptor is provided as follows ```json - "descriptor" :{ - "type": "se_a_mask", - "sel": [36, 16, 24, 64, 6, 1], - "neuron": [25, 50, 100], - "axis_neuron": 16, - "type_one_side": false, - "resnet_dt": false, - "seed": 1 - } + "descriptor" :{ + "type": "se_a_mask", + "sel": [36, 16, 24, 64, 6, 1], + "neuron": [25, 50, 100], + "axis_neuron": 16, + "type_one_side": false, + "resnet_dt": false, + "seed": 1 + } ``` * The {ref}`type ` of the descriptor is set to `"se_a_mask"`. * {ref}`sel ` gives the maximum number of atoms in input coordinates. It is a list, the length of which is the same as the number of atom types in the system, and `sel[i]` denotes the maximum number of atoms with type `i`. @@ -45,13 +45,13 @@ The construction of the descriptor is given by section {ref}`descriptor ` section for fitting energy. * {ref}`numb_aparam ` gives the dimesion of the `aparam.npy` file. In this example, it is set to 1 and stores the real/virtual sign of the atoms. For real/virtual atoms, the corresponding sign in `aparam.npy` is set to 1/0. diff --git a/doc/model/train-se-atten.md b/doc/model/train-se-atten.md index 8b006346a9..1dfa7eae52 100644 --- a/doc/model/train-se-atten.md +++ b/doc/model/train-se-atten.md @@ -28,20 +28,20 @@ With the training input script, data are also provided in the example directory. An example of the DPA-1 descriptor is provided as follows ```json - "descriptor" :{ - "type": "se_atten", - "rcut_smth": 0.50, - "rcut": 6.00, - "sel": 120, - "neuron": [25, 50, 100], - "axis_neuron": 16, - "resnet_dt": false, - "attn": 128, - "attn_layer": 2, - "attn_mask": false, - "attn_dotr": true, - "seed": 1 - } + "descriptor" :{ + "type": "se_atten", + "rcut_smth": 0.50, + "rcut": 6.00, + "sel": 120, + "neuron": [25, 50, 100], + "axis_neuron": 16, + "resnet_dt": false, + "attn": 128, + "attn_layer": 2, + "attn_mask": false, + "attn_dotr": true, + "seed": 1 + } ``` * The {ref}`type ` of the descriptor is set to `"se_atten"`, which will use DPA-1 structures. * {ref}`rcut ` is the cut-off radius for neighbor searching, and the {ref}`rcut_smth ` gives where the smoothing starts. diff --git a/doc/model/train-se-e2-a-tebd.md b/doc/model/train-se-e2-a-tebd.md index 7528202ff2..da55ef262f 100644 --- a/doc/model/train-se-e2-a-tebd.md +++ b/doc/model/train-se-e2-a-tebd.md @@ -8,27 +8,27 @@ The training input script is similar to that of [`se_e2_a`](train-se-e2-a.md), b The {ref}`model ` defines how the model is constructed, adding a section of type embedding net: ```json "model": { - "type_map": ["O", "H"], - "type_embedding":{ - ... - }, - "descriptor" :{ + "type_map": ["O", "H"], + "type_embedding":{ ... - }, - "fitting_net" : { + }, + "descriptor" :{ ... - } + }, + "fitting_net" : { + ... + } } ``` The model will automatically apply the type embedding approach and generate type embedding vectors. If the type embedding vector is detected, the descriptor and fitting net would take it as a part of the input. The construction of type embedding net is given by {ref}`type_embedding `. An example of {ref}`type_embedding ` is provided as follows ```json - "type_embedding":{ - "neuron": [2, 4, 8], - "resnet_dt": false, - "seed": 1 - } + "type_embedding":{ + "neuron": [2, 4, 8], + "resnet_dt": false, + "seed": 1 + } ``` * The {ref}`neuron ` specifies the size of the type embedding net. From left to right the members denote the sizes of each hidden layer from the input end to the output end, respectively. It takes a one-hot vector as input and output dimension equals to the last dimension of the {ref}`neuron ` list. If the outer layer is twice the size of the inner layer, then the inner layer is copied and concatenated, then a [ResNet architecture](https://arxiv.org/abs/1512.03385) is built between them. * If the option {ref}`resnet_dt ` is set to `true`, then a timestep is used in the ResNet. diff --git a/doc/model/train-se-e2-a.md b/doc/model/train-se-e2-a.md index a043f64716..bad42c9a31 100644 --- a/doc/model/train-se-e2-a.md +++ b/doc/model/train-se-e2-a.md @@ -12,17 +12,17 @@ With the training input script, data are also provided in the example directory. The construction of the descriptor is given by section {ref}`descriptor `. An example of the descriptor is provided as follows ```json - "descriptor" :{ - "type": "se_e2_a", - "rcut_smth": 0.50, - "rcut": 6.00, - "sel": [46, 92], - "neuron": [25, 50, 100], - "type_one_side": true, - "axis_neuron": 16, - "resnet_dt": false, - "seed": 1 - } + "descriptor" :{ + "type": "se_e2_a", + "rcut_smth": 0.50, + "rcut": 6.00, + "sel": [46, 92], + "neuron": [25, 50, 100], + "type_one_side": true, + "axis_neuron": 16, + "resnet_dt": false, + "seed": 1 + } ``` * The {ref}`type ` of the descriptor is set to `"se_e2_a"`. * {ref}`rcut ` is the cut-off radius for neighbor searching, and the {ref}`rcut_smth ` gives where the smoothing starts. diff --git a/doc/model/train-se-e2-r.md b/doc/model/train-se-e2-r.md index f48e10c17b..ea9955c90e 100644 --- a/doc/model/train-se-e2-r.md +++ b/doc/model/train-se-e2-r.md @@ -9,15 +9,15 @@ $deepmd_source_dir/examples/water/se_e2_r/input.json The training input script is very similar to that of [`se_e2_a`](train-se-e2-a.md). The only difference lies in the {ref}`descriptor ` section ```json - "descriptor": { - "type": "se_e2_r", - "sel": [46, 92], - "rcut_smth": 0.50, - "rcut": 6.00, - "neuron": [5, 10, 20], - "resnet_dt": false, - "seed": 1, - "_comment": " that's all" - }, + "descriptor": { + "type": "se_e2_r", + "sel": [46, 92], + "rcut_smth": 0.50, + "rcut": 6.00, + "neuron": [5, 10, 20], + "resnet_dt": false, + "seed": 1, + "_comment": " that's all" + }, ``` The type of the descriptor is set by the key {ref}`type `. diff --git a/doc/model/train-se-e3.md b/doc/model/train-se-e3.md index d59f11b264..e7387005f1 100644 --- a/doc/model/train-se-e3.md +++ b/doc/model/train-se-e3.md @@ -9,15 +9,15 @@ $deepmd_source_dir/examples/water/se_e3/input.json The training input script is very similar to that of [`se_e2_a`](train-se-e2-a.md). The only difference lies in the `descriptor ` section ```json - "descriptor": { - "type": "se_e3", - "sel": [40, 80], - "rcut_smth": 0.50, - "rcut": 6.00, - "neuron": [2, 4, 8], - "resnet_dt": false, - "seed": 1, - "_comment": " that's all" - }, + "descriptor": { + "type": "se_e3", + "sel": [40, 80], + "rcut_smth": 0.50, + "rcut": 6.00, + "neuron": [2, 4, 8], + "resnet_dt": false, + "seed": 1, + "_comment": " that's all" + }, ``` The type of the descriptor is set by the key {ref}`type `. diff --git a/doc/sphinx_contrib_exhale_multiproject.py b/doc/sphinx_contrib_exhale_multiproject.py index 208637aa5e..cf0cc9850f 100644 --- a/doc/sphinx_contrib_exhale_multiproject.py +++ b/doc/sphinx_contrib_exhale_multiproject.py @@ -74,9 +74,7 @@ import os import os.path -from pprint import ( - pprint, -) +from pprint import pprint import exhale import exhale.configs diff --git a/doc/third-party/ipi.md b/doc/third-party/ipi.md index 59decdf3bb..50fff4c18c 100644 --- a/doc/third-party/ipi.md +++ b/doc/third-party/ipi.md @@ -9,16 +9,16 @@ It is noted that multiple instances of the client allow for computing, in parall `water.json` is the parameter file for the client `dp_ipi`, and an example is provided: ```json { - "verbose": false, - "use_unix": true, - "port": 31415, - "host": "localhost", - "graph_file": "graph.pb", - "coord_file": "conf.xyz", + "verbose": false, + "use_unix": true, + "port": 31415, + "host": "localhost", + "graph_file": "graph.pb", + "coord_file": "conf.xyz", "atom_type" : { - "OW": 0, - "HW1": 1, - "HW2": 1 + "OW": 0, + "HW1": 1, + "HW2": 1 } } ``` diff --git a/doc/third-party/lammps-command.md b/doc/third-party/lammps-command.md index eae377eb55..9b4f229c6d 100644 --- a/doc/third-party/lammps-command.md +++ b/doc/third-party/lammps-command.md @@ -123,10 +123,10 @@ dump 1 all custom 100 water.dump id type c_dipole[1] c_dipole[2] c_di ## Long-range interaction The reciprocal space part of the long-range interaction can be calculated by LAMMPS command `kspace_style`. To use it with DeePMD-kit, one writes ```lammps -pair_style deepmd graph.pb +pair_style deepmd graph.pb pair_coeff * * -kspace_style pppm 1.0e-5 -kspace_modify gewald 0.45 +kspace_style pppm 1.0e-5 +kspace_modify gewald 0.45 ``` Please notice that the DeePMD does nothing to the direct space part of the electrostatic interaction, because this part is assumed to be fitted in the DeePMD model (the direct space cut-off is thus the cut-off of the DeePMD model). The splitting parameter `gewald` is modified by the `kspace_modify` command. diff --git a/doc/third-party/out-of-deepmd-kit.md b/doc/third-party/out-of-deepmd-kit.md index 6cd5769fbf..fcf3e30451 100644 --- a/doc/third-party/out-of-deepmd-kit.md +++ b/doc/third-party/out-of-deepmd-kit.md @@ -1,35 +1,35 @@ -# Interfaces out of DeePMD-kit - -The codes of the following interfaces are not a part of the DeePMD-kit package and maintained by other repositories. We list these interfaces here for user convenience. - -## dpdata - -[dpdata](https://github.com/deepmodeling/dpdata) provides the `predict` method for `System` class: - -```py -import dpdata -dsys = dpdata.LabeledSystem('OUTCAR') -dp_sys = dsys.predict("frozen_model_compressed.pb") -``` - -By inferring with the DP model `frozen_model_compressed.pb`, dpdata will generate a new labeled system `dp_sys` with inferred energies, forces, and virials. - -## OpenMM plugin for DeePMD-kit - -An [OpenMM](https://github.com/openmm/openmm) plugin is provided from [JingHuangLab/openmm_deepmd_plugin](https://github.com/JingHuangLab/openmm_deepmd_plugin), written by the [Huang Lab](http://www.compbiophysics.org/) at Westlake University. - -## AMBER interface to DeePMD-kit - -An [AMBER](https://ambermd.org/) interface to DeePMD-kit is written by the [York [Lab](https://theory.rutgers.edu/) from Rutgers University. It is open-source at [GitLab RutgersLBSR/AmberDPRc](https://gitlab.com/RutgersLBSR/AmberDPRc/). Details can be found in [this paper](https://doi.org/10.1021/acs.jctc.1c00201). - -## DP-GEN - -[DP-GEN](https://github.com/deepmodeling/dpgen) provides a workflow to generate accurate DP models by calling DeePMD-kit's command line interface (CLI) in the local or remote server. Details can be found in [this paper](https://doi.org/10.1016/j.cpc.2020.107206). - -## MLatom - -[Mlatom](http://mlatom.com/) provides an interface to the DeePMD-kit within MLatom's workflow by calling DeePMD-kit's CLI. Details can be found in [this paper](https://doi.org/10.1007/s41061-021-00339-5). - -## ABACUS - -[ABACUS](https://github.com/deepmodeling/abacus-develop/) can run molecular dynamics with a DP model. User is required to [build ABACUS with DeePMD-kit](https://abacus.deepmodeling.com/en/latest/advanced/install.html#build-with-deepmd-kit). +# Interfaces out of DeePMD-kit + +The codes of the following interfaces are not a part of the DeePMD-kit package and maintained by other repositories. We list these interfaces here for user convenience. + +## dpdata + +[dpdata](https://github.com/deepmodeling/dpdata) provides the `predict` method for `System` class: + +```py +import dpdata +dsys = dpdata.LabeledSystem('OUTCAR') +dp_sys = dsys.predict("frozen_model_compressed.pb") +``` + +By inferring with the DP model `frozen_model_compressed.pb`, dpdata will generate a new labeled system `dp_sys` with inferred energies, forces, and virials. + +## OpenMM plugin for DeePMD-kit + +An [OpenMM](https://github.com/openmm/openmm) plugin is provided from [JingHuangLab/openmm_deepmd_plugin](https://github.com/JingHuangLab/openmm_deepmd_plugin), written by the [Huang Lab](http://www.compbiophysics.org/) at Westlake University. + +## AMBER interface to DeePMD-kit + +An [AMBER](https://ambermd.org/) interface to DeePMD-kit is written by the [York [Lab](https://theory.rutgers.edu/) from Rutgers University. It is open-source at [GitLab RutgersLBSR/AmberDPRc](https://gitlab.com/RutgersLBSR/AmberDPRc/). Details can be found in [this paper](https://doi.org/10.1021/acs.jctc.1c00201). + +## DP-GEN + +[DP-GEN](https://github.com/deepmodeling/dpgen) provides a workflow to generate accurate DP models by calling DeePMD-kit's command line interface (CLI) in the local or remote server. Details can be found in [this paper](https://doi.org/10.1016/j.cpc.2020.107206). + +## MLatom + +[Mlatom](http://mlatom.com/) provides an interface to the DeePMD-kit within MLatom's workflow by calling DeePMD-kit's CLI. Details can be found in [this paper](https://doi.org/10.1007/s41061-021-00339-5). + +## ABACUS + +[ABACUS](https://github.com/deepmodeling/abacus-develop/) can run molecular dynamics with a DP model. User is required to [build ABACUS with DeePMD-kit](https://abacus.deepmodeling.com/en/latest/advanced/install.html#build-with-deepmd-kit). diff --git a/doc/train/tensorboard.md b/doc/train/tensorboard.md index 4846005216..fd17ebf254 100644 --- a/doc/train/tensorboard.md +++ b/doc/train/tensorboard.md @@ -23,29 +23,29 @@ directory by modifying the input script, setting {ref}`tensorboard ` section in `input.json` is given as follows ```json "learning_rate" :{ - "type": "exp", - "start_lr": 0.001, - "stop_lr": 3.51e-8, - "decay_steps": 5000, - "_comment": "that's all" + "type": "exp", + "start_lr": 0.001, + "stop_lr": 3.51e-8, + "decay_steps": 5000, + "_comment": "that's all" } ``` * {ref}`start_lr ` gives the learning rate at the beginning of the training. @@ -31,25 +31,25 @@ where $t$ is the training step, $\alpha$ is the learning rate, $\alpha_0$ is the Other training parameters are given in the {ref}`training ` section. ```json "training": { - "training_data": { - "systems": ["../data_water/data_0/", "../data_water/data_1/", "../data_water/data_2/"], - "batch_size": "auto" - }, - "validation_data":{ - "systems": ["../data_water/data_3"], - "batch_size": 1, - "numb_btch": 3 - }, - "mixed_precision": { - "output_prec": "float32", - "compute_prec": "float16" - }, - - "numb_steps": 1000000, - "seed": 1, - "disp_file": "lcurve.out", - "disp_freq": 100, - "save_freq": 1000 + "training_data": { + "systems": ["../data_water/data_0/", "../data_water/data_1/", "../data_water/data_2/"], + "batch_size": "auto" + }, + "validation_data":{ + "systems": ["../data_water/data_3"], + "batch_size": 1, + "numb_btch": 3 + }, + "mixed_precision": { + "output_prec": "float32", + "compute_prec": "float16" + }, + + "numb_steps": 1000000, + "seed": 1, + "disp_file": "lcurve.out", + "disp_freq": 100, + "save_freq": 1000 } ``` The sections {ref}`training_data ` and {ref}`validation_data ` give the training dataset and validation dataset, respectively. Taking the training dataset for example, the keys are explained below: @@ -62,19 +62,19 @@ The sections {ref}`training_data ` and {ref}`validation_ * `"prob_sys_size; sidx_0:eidx_0:w_0; sidx_1:eidx_1:w_1;..."` the `list` of systems is divided into blocks. Block `i` has systems ranging from `sidx_i` to `eidx_i`. The probability of using a system from block `i` is proportional to `w_i`. Within one block, the probability of using a system is proportional to its size. * An example of using `"auto_prob"` is given below. The probability of using `systems[2]` is 0.4, and the sum of the probabilities of using `systems[0]` and `systems[1]` is 0.6. If the number of frames in `systems[1]` is twice of `system[0]`, then the probability of using `system[1]` is 0.4 and that of `system[0]` is 0.2. ```json - "training_data": { - "systems": ["../data_water/data_0/", "../data_water/data_1/", "../data_water/data_2/"], - "auto_prob": "prob_sys_size; 0:2:0.6; 2:3:0.4", - "batch_size": "auto" - } + "training_data": { + "systems": ["../data_water/data_0/", "../data_water/data_1/", "../data_water/data_2/"], + "auto_prob": "prob_sys_size; 0:2:0.6; 2:3:0.4", + "batch_size": "auto" + } ``` * The probability of using systems can also be specified explicitly with key {ref}`sys_probs ` which is a list having the length of the number of systems. For example ```json - "training_data": { - "systems": ["../data_water/data_0/", "../data_water/data_1/", "../data_water/data_2/"], - "sys_probs": [0.5, 0.3, 0.2], - "batch_size": "auto:32" - } + "training_data": { + "systems": ["../data_water/data_0/", "../data_water/data_1/", "../data_water/data_2/"], + "sys_probs": [0.5, 0.3, 0.2], + "batch_size": "auto:32" + } ``` * The key {ref}`batch_size ` specifies the number of frames used to train or validate the model in a training step. It can be set to * `list`: the length of which is the same as the {ref}`systems`. The batch size of each system is given by the elements of the list. @@ -145,15 +145,15 @@ One can set other environmental variables: One can use `--init-frz-model` features to adjust (increase or decrease) [`sel`](../model/sel.md) of a existing model. Firstly, one needs to adjust [`sel`](./train-input.rst) in `input.json`. For example, adjust from `[46, 92]` to `[23, 46]`. ```json "model": { - "descriptor": { - "sel": [23, 46] - } + "descriptor": { + "sel": [23, 46] + } } ``` To obtain the new model at once, [`numb_steps`](./train-input.rst) should be set to zero: ```json "training": { - "numb_steps": 0 + "numb_steps": 0 } ``` diff --git a/source/install/build_tf.py b/source/install/build_tf.py index 883c654b5c..4a304676f1 100755 --- a/source/install/build_tf.py +++ b/source/install/build_tf.py @@ -32,33 +32,19 @@ import tarfile import tempfile import urllib.request -from abc import ( - ABCMeta, - abstractmethod, - abstractproperty, -) -from contextlib import ( - contextmanager, -) -from fnmatch import ( - filter, -) -from functools import ( - lru_cache, -) -from pathlib import ( - Path, -) -from shutil import ( - copy2, - copytree, - ignore_patterns, -) -from typing import ( - Dict, - List, - Optional, -) +from abc import ABCMeta +from abc import abstractmethod +from abc import abstractproperty +from contextlib import contextmanager +from fnmatch import filter +from functools import lru_cache +from pathlib import Path +from shutil import copy2 +from shutil import copytree +from shutil import ignore_patterns +from typing import Dict +from typing import List +from typing import Optional # default config FILE = Path(__file__).parent.absolute() diff --git a/source/lmp/tests/test_deeptensor.py b/source/lmp/tests/test_deeptensor.py index 0029247959..32fad73404 100644 --- a/source/lmp/tests/test_deeptensor.py +++ b/source/lmp/tests/test_deeptensor.py @@ -1,18 +1,12 @@ import os import subprocess as sp import sys -from pathlib import ( - Path, -) +from pathlib import Path import numpy as np import pytest -from lammps import ( - PyLammps, -) -from write_lmp_data import ( - write_lmp_data, -) +from lammps import PyLammps +from write_lmp_data import write_lmp_data pbtxt_file = Path(__file__).parent.parent.parent / "tests" / "infer" / "deeppot.pbtxt" pb_file = Path(__file__).parent / "graph.pb" diff --git a/source/lmp/tests/test_dplr.py b/source/lmp/tests/test_dplr.py index b6398b77be..0d0efad2c8 100644 --- a/source/lmp/tests/test_dplr.py +++ b/source/lmp/tests/test_dplr.py @@ -1,18 +1,12 @@ import os import subprocess as sp import sys -from pathlib import ( - Path, -) +from pathlib import Path import numpy as np import pytest -from lammps import ( - PyLammps, -) -from write_lmp_data import ( - write_lmp_data_full, -) +from lammps import PyLammps +from write_lmp_data import write_lmp_data_full pbtxt_file = Path(__file__).parent / "lrmodel.pbtxt" pb_file = Path(__file__).parent / "lrmodel.pb" diff --git a/source/lmp/tests/test_lammps.py b/source/lmp/tests/test_lammps.py index f5cb7bac14..e5e7eff307 100644 --- a/source/lmp/tests/test_lammps.py +++ b/source/lmp/tests/test_lammps.py @@ -1,18 +1,12 @@ import os import subprocess as sp import sys -from pathlib import ( - Path, -) +from pathlib import Path import numpy as np import pytest -from lammps import ( - PyLammps, -) -from write_lmp_data import ( - write_lmp_data, -) +from lammps import PyLammps +from write_lmp_data import write_lmp_data pbtxt_file = Path(__file__).parent.parent.parent / "tests" / "infer" / "deeppot.pbtxt" pbtxt_file2 = ( diff --git a/source/lmp/tests/test_lammps_3types.py b/source/lmp/tests/test_lammps_3types.py index 24ef0fae38..07843cdfd2 100644 --- a/source/lmp/tests/test_lammps_3types.py +++ b/source/lmp/tests/test_lammps_3types.py @@ -1,18 +1,12 @@ import os import subprocess as sp import sys -from pathlib import ( - Path, -) +from pathlib import Path import numpy as np import pytest -from lammps import ( - PyLammps, -) -from write_lmp_data import ( - write_lmp_data, -) +from lammps import PyLammps +from write_lmp_data import write_lmp_data pbtxt_file = Path(__file__).parent.parent.parent / "tests" / "infer" / "deeppot.pbtxt" pbtxt_file2 = ( diff --git a/source/op/_add_flt_nvnmd_grad.py b/source/op/_add_flt_nvnmd_grad.py index 0eedd0372c..b001602507 100644 --- a/source/op/_add_flt_nvnmd_grad.py +++ b/source/op/_add_flt_nvnmd_grad.py @@ -1,12 +1,8 @@ #!/usr/bin/env python3 -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_module, -) +from deepmd.env import op_module @ops.RegisterGradient("AddFltNvnmd") diff --git a/source/op/_copy_flt_nvnmd_grad.py b/source/op/_copy_flt_nvnmd_grad.py index 47b8956143..2dbcfcbc49 100644 --- a/source/op/_copy_flt_nvnmd_grad.py +++ b/source/op/_copy_flt_nvnmd_grad.py @@ -1,12 +1,8 @@ #!/usr/bin/env python3 -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_module, -) +from deepmd.env import op_module @ops.RegisterGradient("CopyFltNvnmd") diff --git a/source/op/_dotmul_flt_nvnmd_grad.py b/source/op/_dotmul_flt_nvnmd_grad.py index 97653b1540..42bc2614f3 100644 --- a/source/op/_dotmul_flt_nvnmd_grad.py +++ b/source/op/_dotmul_flt_nvnmd_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_module, - tf, -) +from deepmd.env import op_module +from deepmd.env import tf @ops.RegisterGradient("DotmulFltNvnmd") diff --git a/source/op/_flt_nvnmd_grad.py b/source/op/_flt_nvnmd_grad.py index 471bc35b1c..58408ad616 100644 --- a/source/op/_flt_nvnmd_grad.py +++ b/source/op/_flt_nvnmd_grad.py @@ -1,12 +1,8 @@ #!/usr/bin/env python3 -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_module, -) +from deepmd.env import op_module @ops.RegisterGradient("FltNvnmd") diff --git a/source/op/_gelu.py b/source/op/_gelu.py index 19b2a3f240..2255ee61be 100644 --- a/source/op/_gelu.py +++ b/source/op/_gelu.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 """First-order derivatives and second-order derivatives for gelu function.""" import tensorflow -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_module, -) +from deepmd.env import op_module try: gelu = tensorflow.nn.gelu diff --git a/source/op/_map_flt_nvnmd_grad.py b/source/op/_map_flt_nvnmd_grad.py index 434701bc6e..caeb3de171 100644 --- a/source/op/_map_flt_nvnmd_grad.py +++ b/source/op/_map_flt_nvnmd_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_module, - tf, -) +from deepmd.env import op_module +from deepmd.env import tf @ops.RegisterGradient("MapFltNvnmd") diff --git a/source/op/_matmul_fitnet_nvnmd_grad.py b/source/op/_matmul_fitnet_nvnmd_grad.py index 77fafb7d24..fa4c92d493 100644 --- a/source/op/_matmul_fitnet_nvnmd_grad.py +++ b/source/op/_matmul_fitnet_nvnmd_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_module, - tf, -) +from deepmd.env import op_module +from deepmd.env import tf @ops.RegisterGradient("MatmulFitnetNvnmd") diff --git a/source/op/_matmul_flt2fix_nvnmd.py b/source/op/_matmul_flt2fix_nvnmd.py index 3b47b14a09..670674103d 100644 --- a/source/op/_matmul_flt2fix_nvnmd.py +++ b/source/op/_matmul_flt2fix_nvnmd.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_module, - tf, -) +from deepmd.env import op_module +from deepmd.env import tf @ops.RegisterGradient("MatmulFlt2fixNvnmd") diff --git a/source/op/_matmul_flt_nvnmd_grad.py b/source/op/_matmul_flt_nvnmd_grad.py index 383e464e64..1e9f980508 100644 --- a/source/op/_matmul_flt_nvnmd_grad.py +++ b/source/op/_matmul_flt_nvnmd_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_module, - tf, -) +from deepmd.env import op_module +from deepmd.env import tf @ops.RegisterGradient("MatmulFltNvnmd") diff --git a/source/op/_mul_flt_nvnmd_grad.py b/source/op/_mul_flt_nvnmd_grad.py index e1fb72ac6b..634fa56484 100644 --- a/source/op/_mul_flt_nvnmd_grad.py +++ b/source/op/_mul_flt_nvnmd_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_module, - tf, -) +from deepmd.env import op_module +from deepmd.env import tf @ops.RegisterGradient("MulFltNvnmd") diff --git a/source/op/_prod_force_grad.py b/source/op/_prod_force_grad.py index 8cdd37675c..3fb5296057 100644 --- a/source/op/_prod_force_grad.py +++ b/source/op/_prod_force_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 """Gradients for prod force.""" -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_grads_module, -) +from deepmd.env import op_grads_module @ops.RegisterGradient("ProdForce") diff --git a/source/op/_prod_force_se_a_grad.py b/source/op/_prod_force_se_a_grad.py index cdfa73e4ad..56e36d8a4a 100644 --- a/source/op/_prod_force_se_a_grad.py +++ b/source/op/_prod_force_se_a_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 """Gradients for prod force.""" -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_grads_module, -) +from deepmd.env import op_grads_module @ops.RegisterGradient("ProdForceSeA") diff --git a/source/op/_prod_force_se_a_mask_grad.py b/source/op/_prod_force_se_a_mask_grad.py index b4c4f8fabc..9fc7a994b7 100644 --- a/source/op/_prod_force_se_a_mask_grad.py +++ b/source/op/_prod_force_se_a_mask_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 """Gradients for prod force se_a_mask.""" -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_grads_module, -) +from deepmd.env import op_grads_module @ops.RegisterGradient("ProdForceSeAMask") diff --git a/source/op/_prod_force_se_r_grad.py b/source/op/_prod_force_se_r_grad.py index 447c388912..0a092961a6 100644 --- a/source/op/_prod_force_se_r_grad.py +++ b/source/op/_prod_force_se_r_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 """Gradients for prod force.""" -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_grads_module, -) +from deepmd.env import op_grads_module @ops.RegisterGradient("ProdForceSeR") diff --git a/source/op/_prod_virial_grad.py b/source/op/_prod_virial_grad.py index aa8cca0939..e4c1bad3d0 100644 --- a/source/op/_prod_virial_grad.py +++ b/source/op/_prod_virial_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 """Gradients for prod virial.""" -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_grads_module, -) +from deepmd.env import op_grads_module @ops.RegisterGradient("ProdVirial") diff --git a/source/op/_prod_virial_se_a_grad.py b/source/op/_prod_virial_se_a_grad.py index 6167795b7c..043bf7b737 100644 --- a/source/op/_prod_virial_se_a_grad.py +++ b/source/op/_prod_virial_se_a_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 """Gradients for prod virial.""" -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_grads_module, -) +from deepmd.env import op_grads_module @ops.RegisterGradient("ProdVirialSeA") diff --git a/source/op/_prod_virial_se_r_grad.py b/source/op/_prod_virial_se_r_grad.py index bb7680203d..c9c395eb7b 100644 --- a/source/op/_prod_virial_se_r_grad.py +++ b/source/op/_prod_virial_se_r_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 """Gradients for prod virial.""" -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_grads_module, -) +from deepmd.env import op_grads_module @ops.RegisterGradient("ProdVirialSeR") diff --git a/source/op/_quantize_nvnmd_grad.py b/source/op/_quantize_nvnmd_grad.py index 64a492c04f..c7d2e1d076 100644 --- a/source/op/_quantize_nvnmd_grad.py +++ b/source/op/_quantize_nvnmd_grad.py @@ -1,12 +1,8 @@ #!/usr/bin/env python3 -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_module, -) +from deepmd.env import op_module @ops.RegisterGradient("QuantizeNvnmd") diff --git a/source/op/_soft_min_force_grad.py b/source/op/_soft_min_force_grad.py index c8519886d5..0ea5db0c6d 100644 --- a/source/op/_soft_min_force_grad.py +++ b/source/op/_soft_min_force_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 """Gradients for soft min force.""" -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_grads_module, -) +from deepmd.env import op_grads_module @ops.RegisterGradient("SoftMinForce") diff --git a/source/op/_soft_min_virial_grad.py b/source/op/_soft_min_virial_grad.py index f35bba9080..a12050ee6a 100644 --- a/source/op/_soft_min_virial_grad.py +++ b/source/op/_soft_min_virial_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 """Gradients for soft min virial.""" -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_grads_module, -) +from deepmd.env import op_grads_module @ops.RegisterGradient("SoftMinVirial") diff --git a/source/op/_tabulate_grad.py b/source/op/_tabulate_grad.py index 785146cfcc..369d584e9e 100644 --- a/source/op/_tabulate_grad.py +++ b/source/op/_tabulate_grad.py @@ -1,13 +1,9 @@ #!/usr/bin/env python3 """Gradients for tabulate.""" -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - op_module, -) +from deepmd.env import op_module # from deepmd.DescrptSeATabulate import last_layer_size diff --git a/source/op/_tanh4_flt_nvnmd_grad.py b/source/op/_tanh4_flt_nvnmd_grad.py index 9ccfe701df..bcfc01dbe9 100644 --- a/source/op/_tanh4_flt_nvnmd_grad.py +++ b/source/op/_tanh4_flt_nvnmd_grad.py @@ -1,12 +1,8 @@ #!/usr/bin/env python3 -from tensorflow.python.framework import ( - ops, -) +from tensorflow.python.framework import ops -from deepmd.env import ( - tf, -) +from deepmd.env import tf @ops.RegisterGradient("Tanh4FltNvnmd") diff --git a/source/tests/common.py b/source/tests/common.py index dcbccd221a..a450fcca00 100644 --- a/source/tests/common.py +++ b/source/tests/common.py @@ -8,13 +8,9 @@ import numpy as np from deepmd.common import j_loader as dp_j_loader -from deepmd.entrypoints.main import ( - main, -) -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - tf, -) +from deepmd.entrypoints.main import main +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import tf from deepmd.utils import random as dp_random if GLOBAL_NP_FLOAT_PRECISION == np.float32: diff --git a/source/tests/test_activation_fn_gelu.py b/source/tests/test_activation_fn_gelu.py index 4b0a430c35..ade5afab21 100644 --- a/source/tests/test_activation_fn_gelu.py +++ b/source/tests/test_activation_fn_gelu.py @@ -2,15 +2,9 @@ import numpy as np -from deepmd.common import ( - get_activation_func, -) -from deepmd.env import ( - tf, -) -from deepmd.utils.network import ( - embedding_net, -) +from deepmd.common import get_activation_func +from deepmd.env import tf +from deepmd.utils.network import embedding_net class TestGelu(tf.test.TestCase): diff --git a/source/tests/test_adjust_sel.py b/source/tests/test_adjust_sel.py index f7908af01c..f9d876f8df 100644 --- a/source/tests/test_adjust_sel.py +++ b/source/tests/test_adjust_sel.py @@ -6,18 +6,12 @@ import numpy as np # from deepmd.entrypoints.compress import compress -from common import ( - j_loader, - run_dp, - tests_path, -) +from common import j_loader +from common import run_dp +from common import tests_path -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.infer import ( - DeepPot, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.infer import DeepPot if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_argument_parser.py b/source/tests/test_argument_parser.py index e48a2da24b..2dd1cf0646 100644 --- a/source/tests/test_argument_parser.py +++ b/source/tests/test_argument_parser.py @@ -2,28 +2,18 @@ import re import unittest -from argparse import ( - Namespace, -) -from contextlib import ( - redirect_stderr, -) -from io import ( - StringIO, -) -from typing import ( - TYPE_CHECKING, - Any, - Dict, - List, - Tuple, - Union, -) - -from deepmd.entrypoints.main import ( - get_ll, - parse_args, -) +from argparse import Namespace +from contextlib import redirect_stderr +from io import StringIO +from typing import TYPE_CHECKING +from typing import Any +from typing import Dict +from typing import List +from typing import Tuple +from typing import Union + +from deepmd.entrypoints.main import get_ll +from deepmd.entrypoints.main import parse_args if TYPE_CHECKING: try: diff --git a/source/tests/test_auto_batch_size.py b/source/tests/test_auto_batch_size.py index bd863b2633..5fa7e2c4f7 100644 --- a/source/tests/test_auto_batch_size.py +++ b/source/tests/test_auto_batch_size.py @@ -3,12 +3,8 @@ import numpy as np -from deepmd.utils.batch_size import ( - AutoBatchSize, -) -from deepmd.utils.errors import ( - OutOfMemoryError, -) +from deepmd.utils.batch_size import AutoBatchSize +from deepmd.utils.errors import OutOfMemoryError class TestAutoBatchSize(unittest.TestCase): diff --git a/source/tests/test_cluster.py b/source/tests/test_cluster.py index ceaddf41d4..53a2ace763 100644 --- a/source/tests/test_cluster.py +++ b/source/tests/test_cluster.py @@ -1,12 +1,8 @@ import unittest -from unittest import ( - mock, -) - -from deepmd.cluster import ( - local, - slurm, -) +from unittest import mock + +from deepmd.cluster import local +from deepmd.cluster import slurm kHostName = "compute-b24-1" diff --git a/source/tests/test_common.py b/source/tests/test_common.py index c3d6172f5b..7bfe700a51 100644 --- a/source/tests/test_common.py +++ b/source/tests/test_common.py @@ -1,17 +1,11 @@ import shutil import unittest -from pathlib import ( - Path, -) +from pathlib import Path -from deepmd.common import ( - GLOBAL_TF_FLOAT_PRECISION, - cast_precision, - expand_sys_str, -) -from deepmd.env import ( - tf, -) +from deepmd.common import GLOBAL_TF_FLOAT_PRECISION +from deepmd.common import cast_precision +from deepmd.common import expand_sys_str +from deepmd.env import tf # compute relative path diff --git a/source/tests/test_compat_input.py b/source/tests/test_compat_input.py index df5fcd45f7..91a51e52c6 100644 --- a/source/tests/test_compat_input.py +++ b/source/tests/test_compat_input.py @@ -1,14 +1,10 @@ import os import unittest -from common import ( - j_loader, -) - -from deepmd.utils.compat import ( - convert_input_v0_v1, - convert_input_v1_v2, -) +from common import j_loader + +from deepmd.utils.compat import convert_input_v0_v1 +from deepmd.utils.compat import convert_input_v1_v2 class TestConvertInput(unittest.TestCase): diff --git a/source/tests/test_data_large_batch.py b/source/tests/test_data_large_batch.py index 531c6de4f3..ba7f425c6d 100644 --- a/source/tests/test_data_large_batch.py +++ b/source/tests/test_data_large_batch.py @@ -1,33 +1,17 @@ import unittest import numpy as np -from common import ( - gen_data, - j_loader, -) +from common import gen_data +from common import j_loader from packaging.version import parse as parse_version -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeAtten, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model import ( - EnerModel, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) -from deepmd.utils.type_embed import ( - TypeEmbedNet, -) +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeAtten +from deepmd.env import tf +from deepmd.fit import EnerFitting +from deepmd.model import EnerModel +from deepmd.utils.data_system import DeepmdDataSystem +from deepmd.utils.type_embed import TypeEmbedNet GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_data_modifier.py b/source/tests/test_data_modifier.py index 99395f1127..793dc0540f 100644 --- a/source/tests/test_data_modifier.py +++ b/source/tests/test_data_modifier.py @@ -1,32 +1,18 @@ import os import numpy as np -from common import ( - Data, - j_loader, - tests_path, -) - -from deepmd.common import ( - data_requirement, - j_must_have, -) -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - tf, -) -from deepmd.infer.data_modifier import ( - DipoleChargeModifier, -) -from deepmd.train.run_options import ( - RunOptions, -) -from deepmd.train.trainer import ( - DPTrainer, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) +from common import Data +from common import j_loader +from common import tests_path + +from deepmd.common import data_requirement +from deepmd.common import j_must_have +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.infer.data_modifier import DipoleChargeModifier +from deepmd.train.run_options import RunOptions +from deepmd.train.trainer import DPTrainer +from deepmd.utils.data_system import DeepmdDataSystem if GLOBAL_NP_FLOAT_PRECISION == np.float32: global_default_fv_hh = 1e-2 diff --git a/source/tests/test_data_modifier_shuffle.py b/source/tests/test_data_modifier_shuffle.py index 7a7a9628e1..62725407de 100644 --- a/source/tests/test_data_modifier_shuffle.py +++ b/source/tests/test_data_modifier_shuffle.py @@ -3,29 +3,15 @@ import numpy as np -from deepmd.common import ( - data_requirement, - j_must_have, -) -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - tf, -) -from deepmd.infer.data_modifier import ( - DipoleChargeModifier, -) -from deepmd.infer.deep_dipole import ( - DeepDipole, -) -from deepmd.train.run_options import ( - RunOptions, -) -from deepmd.train.trainer import ( - DPTrainer, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) +from deepmd.common import data_requirement +from deepmd.common import j_must_have +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.infer.data_modifier import DipoleChargeModifier +from deepmd.infer.deep_dipole import DeepDipole +from deepmd.train.run_options import RunOptions +from deepmd.train.trainer import DPTrainer +from deepmd.utils.data_system import DeepmdDataSystem if GLOBAL_NP_FLOAT_PRECISION == np.float32: global_default_fv_hh = 1e-2 diff --git a/source/tests/test_data_requirement.py b/source/tests/test_data_requirement.py index c407e3d5bd..cc204cc818 100644 --- a/source/tests/test_data_requirement.py +++ b/source/tests/test_data_requirement.py @@ -1,9 +1,7 @@ import unittest -from deepmd.common import ( - add_data_requirement, - data_requirement, -) +from deepmd.common import add_data_requirement +from deepmd.common import data_requirement class TestDataRequirement(unittest.TestCase): diff --git a/source/tests/test_deepdipole.py b/source/tests/test_deepdipole.py index ee96a74392..7b41f1d244 100644 --- a/source/tests/test_deepdipole.py +++ b/source/tests/test_deepdipole.py @@ -2,23 +2,15 @@ import unittest import numpy as np -from common import ( - finite_difference, - strerch_box, - tests_path, - tf, -) +from common import finite_difference +from common import strerch_box +from common import tests_path +from common import tf from packaging.version import parse as parse_version -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.infer import ( - DeepDipole, -) -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.infer import DeepDipole +from deepmd.utils.convert import convert_pbtxt_to_pb if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_deepdos.py b/source/tests/test_deepdos.py index c8968c04d5..2d405ee201 100644 --- a/source/tests/test_deepdos.py +++ b/source/tests/test_deepdos.py @@ -2,19 +2,11 @@ import unittest import numpy as np -from common import ( - tests_path, -) +from common import tests_path -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.infer import ( - DeepDOS, -) -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.infer import DeepDOS +from deepmd.utils.convert import convert_pbtxt_to_pb if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_deepmd_data.py b/source/tests/test_deepmd_data.py index 3861b37312..1166ab9950 100644 --- a/source/tests/test_deepmd_data.py +++ b/source/tests/test_deepmd_data.py @@ -4,16 +4,10 @@ import unittest import numpy as np -from common import ( - tests_path, -) +from common import tests_path -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.utils.data import ( - DeepmdData, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.utils.data import DeepmdData if GLOBAL_NP_FLOAT_PRECISION == np.float32: places = 6 diff --git a/source/tests/test_deepmd_data_sys.py b/source/tests/test_deepmd_data_sys.py index 5ed9d3d3f6..4b1d6d9509 100644 --- a/source/tests/test_deepmd_data_sys.py +++ b/source/tests/test_deepmd_data_sys.py @@ -4,15 +4,9 @@ import numpy as np -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.utils import ( - random, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.utils import random +from deepmd.utils.data_system import DeepmdDataSystem if GLOBAL_NP_FLOAT_PRECISION == np.float32: places = 6 diff --git a/source/tests/test_deeppolar.py b/source/tests/test_deeppolar.py index 10c2fefb33..28530580e8 100644 --- a/source/tests/test_deeppolar.py +++ b/source/tests/test_deeppolar.py @@ -2,21 +2,13 @@ import unittest import numpy as np -from common import ( - tests_path, - tf, -) +from common import tests_path +from common import tf from packaging.version import parse as parse_version -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.infer import ( - DeepPolar, -) -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.infer import DeepPolar +from deepmd.utils.convert import convert_pbtxt_to_pb if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_deeppot_a.py b/source/tests/test_deeppot_a.py index a0a3bd0f33..57cf70beaf 100644 --- a/source/tests/test_deeppot_a.py +++ b/source/tests/test_deeppot_a.py @@ -3,27 +3,19 @@ import unittest import numpy as np -from common import ( - run_dp, - tests_path, -) +from common import run_dp +from common import tests_path -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - MODEL_VERSION, -) -from deepmd.infer import ( - DeepPot, -) -from deepmd.utils.convert import ( - convert_dp10_to_dp11, - convert_dp012_to_dp10, - convert_dp12_to_dp13, - convert_dp13_to_dp20, - convert_dp20_to_dp21, - convert_pbtxt_to_pb, - detect_model_version, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import MODEL_VERSION +from deepmd.infer import DeepPot +from deepmd.utils.convert import convert_dp10_to_dp11 +from deepmd.utils.convert import convert_dp012_to_dp10 +from deepmd.utils.convert import convert_dp12_to_dp13 +from deepmd.utils.convert import convert_dp13_to_dp20 +from deepmd.utils.convert import convert_dp20_to_dp21 +from deepmd.utils.convert import convert_pbtxt_to_pb +from deepmd.utils.convert import detect_model_version if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 @@ -672,13 +664,9 @@ def test_1frame_atm(self): np.testing.assert_almost_equal(vv.ravel(), expected_sv.ravel(), default_places) def test_ase(self): - from ase import ( - Atoms, - ) + from ase import Atoms - from deepmd.calculator import ( - DP, - ) + from deepmd.calculator import DP water = Atoms( "OHHOHH", diff --git a/source/tests/test_deeppot_r.py b/source/tests/test_deeppot_r.py index 36d840b831..acc11b8305 100644 --- a/source/tests/test_deeppot_r.py +++ b/source/tests/test_deeppot_r.py @@ -2,19 +2,11 @@ import unittest import numpy as np -from common import ( - tests_path, -) +from common import tests_path -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.infer import ( - DeepPot, -) -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.infer import DeepPot +from deepmd.utils.convert import convert_pbtxt_to_pb if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_deeppot_spin.py b/source/tests/test_deeppot_spin.py index 516633b9e6..0d4db8fd57 100644 --- a/source/tests/test_deeppot_spin.py +++ b/source/tests/test_deeppot_spin.py @@ -2,19 +2,11 @@ import unittest import numpy as np -from common import ( - tests_path, -) +from common import tests_path -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.infer import ( - DeepPot, -) -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.infer import DeepPot +from deepmd.utils.convert import convert_pbtxt_to_pb if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_descrpt_nonsmth.py b/source/tests/test_descrpt_nonsmth.py index a0e560c331..3e24465f84 100644 --- a/source/tests/test_descrpt_nonsmth.py +++ b/source/tests/test_descrpt_nonsmth.py @@ -1,21 +1,17 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) +from common import Data +from common import force_dw_test +from common import force_test +from common import virial_dw_test +from common import virial_test # load grad of force module -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf class Inter: diff --git a/source/tests/test_descrpt_se_a_mask.py b/source/tests/test_descrpt_se_a_mask.py index b5281b0ed4..d5011f9c58 100644 --- a/source/tests/test_descrpt_se_a_mask.py +++ b/source/tests/test_descrpt_se_a_mask.py @@ -2,26 +2,14 @@ import pathlib import numpy as np -from common import ( - DataSystem, - j_loader, -) +from common import DataSystem +from common import j_loader -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeAMask, -) -from deepmd.env import ( - tf, -) -from deepmd.infer import ( - DeepPot, -) -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeAMask +from deepmd.env import tf +from deepmd.infer import DeepPot +from deepmd.utils.convert import convert_pbtxt_to_pb GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_descrpt_se_a_type.py b/source/tests/test_descrpt_se_a_type.py index e143709b47..604a909b85 100644 --- a/source/tests/test_descrpt_se_a_type.py +++ b/source/tests/test_descrpt_se_a_type.py @@ -1,22 +1,12 @@ import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.utils.type_embed import ( - TypeEmbedNet, -) +from common import DataSystem +from common import gen_data +from common import j_loader + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.utils.type_embed import TypeEmbedNet GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_descrpt_se_atten.py b/source/tests/test_descrpt_se_atten.py index cfa2cdaae5..459190ac16 100644 --- a/source/tests/test_descrpt_se_atten.py +++ b/source/tests/test_descrpt_se_atten.py @@ -1,25 +1,15 @@ import unittest import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) +from common import DataSystem +from common import gen_data +from common import j_loader from packaging.version import parse as parse_version -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeAtten, -) -from deepmd.env import ( - tf, -) -from deepmd.utils.type_embed import ( - TypeEmbedNet, -) +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeAtten +from deepmd.env import tf +from deepmd.utils.type_embed import TypeEmbedNet GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_descrpt_se_r.py b/source/tests/test_descrpt_se_r.py index 362d64f58d..6778136b91 100644 --- a/source/tests/test_descrpt_se_r.py +++ b/source/tests/test_descrpt_se_r.py @@ -1,21 +1,17 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) +from common import Data +from common import force_dw_test +from common import force_test +from common import virial_dw_test +from common import virial_test # load grad of force module -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf class Inter: diff --git a/source/tests/test_descrpt_sea_ef.py b/source/tests/test_descrpt_sea_ef.py index ef0712c5ae..545920cd3e 100644 --- a/source/tests/test_descrpt_sea_ef.py +++ b/source/tests/test_descrpt_sea_ef.py @@ -1,21 +1,17 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) +from common import Data +from common import force_dw_test +from common import force_test +from common import virial_dw_test +from common import virial_test # load grad of force module -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf class Inter: diff --git a/source/tests/test_descrpt_sea_ef_para.py b/source/tests/test_descrpt_sea_ef_para.py index 68696ac4f0..f7dff2151f 100644 --- a/source/tests/test_descrpt_sea_ef_para.py +++ b/source/tests/test_descrpt_sea_ef_para.py @@ -1,21 +1,17 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) +from common import Data +from common import force_dw_test +from common import force_test +from common import virial_dw_test +from common import virial_test # load grad of force module -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf class Inter: diff --git a/source/tests/test_descrpt_sea_ef_rot.py b/source/tests/test_descrpt_sea_ef_rot.py index cdeb51350e..9098422662 100644 --- a/source/tests/test_descrpt_sea_ef_rot.py +++ b/source/tests/test_descrpt_sea_ef_rot.py @@ -2,16 +2,12 @@ import numpy as np -from deepmd.descriptor import ( - DescrptSeA, - DescrptSeAEfLower, -) -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) +from deepmd.descriptor import DescrptSeA +from deepmd.descriptor import DescrptSeAEfLower +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf class TestEfRot(tf.test.TestCase): diff --git a/source/tests/test_descrpt_sea_ef_vert.py b/source/tests/test_descrpt_sea_ef_vert.py index 67269cff77..e8b48583b5 100644 --- a/source/tests/test_descrpt_sea_ef_vert.py +++ b/source/tests/test_descrpt_sea_ef_vert.py @@ -1,21 +1,17 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) +from common import Data +from common import force_dw_test +from common import force_test +from common import virial_dw_test +from common import virial_test # load grad of force module -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf class Inter: diff --git a/source/tests/test_descrpt_smooth.py b/source/tests/test_descrpt_smooth.py index a42bfa91dc..3092ffd8c8 100644 --- a/source/tests/test_descrpt_smooth.py +++ b/source/tests/test_descrpt_smooth.py @@ -1,21 +1,17 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) +from common import Data +from common import force_dw_test +from common import force_test +from common import virial_dw_test +from common import virial_test # load grad of force module -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf class Inter: diff --git a/source/tests/test_dipole_se_a.py b/source/tests/test_dipole_se_a.py index 6203338cf7..ca6bb968e3 100644 --- a/source/tests/test_dipole_se_a.py +++ b/source/tests/test_dipole_se_a.py @@ -1,27 +1,15 @@ import numpy as np -from common import ( - DataSystem, - finite_difference, - gen_data, - j_loader, - strerch_box, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - DipoleFittingSeA, -) -from deepmd.model import ( - DipoleModel, -) +from common import DataSystem +from common import finite_difference +from common import gen_data +from common import j_loader +from common import strerch_box + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import DipoleFittingSeA +from deepmd.model import DipoleModel GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_dipole_se_a_tebd.py b/source/tests/test_dipole_se_a_tebd.py index 5eda943255..2a8fb93e83 100644 --- a/source/tests/test_dipole_se_a_tebd.py +++ b/source/tests/test_dipole_se_a_tebd.py @@ -1,33 +1,19 @@ import unittest import numpy as np -from common import ( - DataSystem, - finite_difference, - gen_data, - j_loader, - strerch_box, -) +from common import DataSystem +from common import finite_difference +from common import gen_data +from common import j_loader +from common import strerch_box from packaging.version import parse as parse_version -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - DipoleFittingSeA, -) -from deepmd.model import ( - DipoleModel, -) -from deepmd.utils.type_embed import ( - TypeEmbedNet, -) +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import DipoleFittingSeA +from deepmd.model import DipoleModel +from deepmd.utils.type_embed import TypeEmbedNet GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_dipolecharge.py b/source/tests/test_dipolecharge.py index 8fce3c2e12..b3119f08eb 100644 --- a/source/tests/test_dipolecharge.py +++ b/source/tests/test_dipolecharge.py @@ -2,19 +2,11 @@ import unittest import numpy as np -from common import ( - tests_path, -) +from common import tests_path -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.infer import ( - DipoleChargeModifier, -) -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.infer import DipoleChargeModifier +from deepmd.utils.convert import convert_pbtxt_to_pb if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_embedding_net.py b/source/tests/test_embedding_net.py index 7fb238e9e2..a50a071af3 100644 --- a/source/tests/test_embedding_net.py +++ b/source/tests/test_embedding_net.py @@ -2,12 +2,8 @@ import numpy as np -from deepmd.env import ( - tf, -) -from deepmd.utils.network import ( - embedding_net, -) +from deepmd.env import tf +from deepmd.utils.network import embedding_net class Inter(tf.test.TestCase): diff --git a/source/tests/test_env.py b/source/tests/test_env.py index e1864306c3..25480f8056 100644 --- a/source/tests/test_env.py +++ b/source/tests/test_env.py @@ -1,11 +1,7 @@ import unittest -from unittest import ( - mock, -) +from unittest import mock -from deepmd import ( - env, -) +from deepmd import env class TestTFThreadCount(unittest.TestCase): diff --git a/source/tests/test_ewald.py b/source/tests/test_ewald.py index 0f6fb85228..b5b805ce74 100644 --- a/source/tests/test_ewald.py +++ b/source/tests/test_ewald.py @@ -1,14 +1,10 @@ import numpy as np -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - tf, -) -from deepmd.infer.ewald_recp import ( - EwaldRecp, - op_module, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.infer.ewald_recp import EwaldRecp +from deepmd.infer.ewald_recp import op_module if GLOBAL_NP_FLOAT_PRECISION == np.float32: global_default_fv_hh = 1e-2 diff --git a/source/tests/test_examples.py b/source/tests/test_examples.py index 138a7205b5..13c0bc2758 100644 --- a/source/tests/test_examples.py +++ b/source/tests/test_examples.py @@ -2,16 +2,10 @@ could pass the argument checking. """ import unittest -from pathlib import ( - Path, -) +from pathlib import Path -from deepmd.common import ( - j_loader, -) -from deepmd.utils.argcheck import ( - normalize, -) +from deepmd.common import j_loader +from deepmd.utils.argcheck import normalize p_examples = Path(__file__).parent.parent.parent / "examples" diff --git a/source/tests/test_finetune_se_atten.py b/source/tests/test_finetune_se_atten.py index 18c89f0153..d0e0601636 100644 --- a/source/tests/test_finetune_se_atten.py +++ b/source/tests/test_finetune_se_atten.py @@ -4,32 +4,18 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) +from common import j_loader +from common import run_dp +from common import tests_path from packaging.version import parse as parse_version -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - tf, -) -from deepmd.infer import ( - DeepPotential, -) -from deepmd.utils.argcheck import ( - normalize, -) -from deepmd.utils.compat import ( - update_deepmd_input, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) -from deepmd.utils.graph import ( - get_tensor_by_name, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.infer import DeepPotential +from deepmd.utils.argcheck import normalize +from deepmd.utils.compat import update_deepmd_input +from deepmd.utils.data_system import DeepmdDataSystem +from deepmd.utils.graph import get_tensor_by_name if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_fitting_dos.py b/source/tests/test_fitting_dos.py index 7e4c5f4c07..c91bf6d3d7 100644 --- a/source/tests/test_fitting_dos.py +++ b/source/tests/test_fitting_dos.py @@ -1,22 +1,12 @@ import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - DOSFitting, -) +from common import DataSystem +from common import gen_data +from common import j_loader + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import DOSFitting GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_fitting_ener_type.py b/source/tests/test_fitting_ener_type.py index ca0c7afd79..fe4c452490 100644 --- a/source/tests/test_fitting_ener_type.py +++ b/source/tests/test_fitting_ener_type.py @@ -1,22 +1,12 @@ import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) +from common import DataSystem +from common import gen_data +from common import j_loader + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import EnerFitting GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_fitting_stat.py b/source/tests/test_fitting_stat.py index 8ea1ff8b68..536f130d7a 100644 --- a/source/tests/test_fitting_stat.py +++ b/source/tests/test_fitting_stat.py @@ -1,19 +1,11 @@ import unittest -from collections import ( - defaultdict, -) +from collections import defaultdict import numpy as np -from common import ( - j_loader, -) +from common import j_loader -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.fit import ( - EnerFitting, -) +from deepmd.descriptor import DescrptSeA +from deepmd.fit import EnerFitting input_json = "water_se_a_afparam.json" diff --git a/source/tests/test_gen_stat_data.py b/source/tests/test_gen_stat_data.py index eac279a3a4..48e7deeb6e 100644 --- a/source/tests/test_gen_stat_data.py +++ b/source/tests/test_gen_stat_data.py @@ -4,21 +4,13 @@ import dpdata import numpy as np -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model.model_stat import ( - _make_all_stat_ref, - make_stat_input, - merge_sys_stat, -) +from deepmd.descriptor import DescrptSeA +from deepmd.fit import EnerFitting +from deepmd.model.model_stat import _make_all_stat_ref +from deepmd.model.model_stat import make_stat_input +from deepmd.model.model_stat import merge_sys_stat from deepmd.utils import random as dp_random -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) +from deepmd.utils.data_system import DeepmdDataSystem def gen_sys(nframes, atom_types): diff --git a/source/tests/test_get_potential.py b/source/tests/test_get_potential.py index 869325e1c3..9d13c48074 100644 --- a/source/tests/test_get_potential.py +++ b/source/tests/test_get_potential.py @@ -1,19 +1,13 @@ """Test if `DeepPotential` facto function returns the right type of potential.""" import unittest -from pathlib import ( - Path, -) - -from deepmd.infer import ( - DeepDipole, - DeepPolar, - DeepPot, - DeepPotential, -) -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) +from pathlib import Path + +from deepmd.infer import DeepDipole +from deepmd.infer import DeepPolar +from deepmd.infer import DeepPot +from deepmd.infer import DeepPotential +from deepmd.utils.convert import convert_pbtxt_to_pb class TestGetPotential(unittest.TestCase): diff --git a/source/tests/test_init_frz_model_multi.py b/source/tests/test_init_frz_model_multi.py index e7cf2a5f7f..b4ea0d42c0 100644 --- a/source/tests/test_init_frz_model_multi.py +++ b/source/tests/test_init_frz_model_multi.py @@ -3,34 +3,18 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) - -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - tf, -) -from deepmd.train.run_options import ( - RunOptions, -) -from deepmd.train.trainer import ( - DPTrainer, -) -from deepmd.utils.argcheck import ( - normalize, -) -from deepmd.utils.compat import ( - update_deepmd_input, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) -from deepmd.utils.multi_init import ( - replace_model_params_with_frz_multi_model, -) +from common import j_loader +from common import run_dp +from common import tests_path + +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.train.run_options import RunOptions +from deepmd.train.trainer import DPTrainer +from deepmd.utils.argcheck import normalize +from deepmd.utils.compat import update_deepmd_input +from deepmd.utils.data_system import DeepmdDataSystem +from deepmd.utils.multi_init import replace_model_params_with_frz_multi_model if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_init_frz_model_se_a.py b/source/tests/test_init_frz_model_se_a.py index 2e73254e84..554a0f0054 100644 --- a/source/tests/test_init_frz_model_se_a.py +++ b/source/tests/test_init_frz_model_se_a.py @@ -3,31 +3,17 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) - -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - tf, -) -from deepmd.train.run_options import ( - RunOptions, -) -from deepmd.train.trainer import ( - DPTrainer, -) -from deepmd.utils.argcheck import ( - normalize, -) -from deepmd.utils.compat import ( - update_deepmd_input, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) +from common import j_loader +from common import run_dp +from common import tests_path + +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.train.run_options import RunOptions +from deepmd.train.trainer import DPTrainer +from deepmd.utils.argcheck import normalize +from deepmd.utils.compat import update_deepmd_input +from deepmd.utils.data_system import DeepmdDataSystem if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_init_frz_model_se_a_type.py b/source/tests/test_init_frz_model_se_a_type.py index dd09f0d3c2..11acc5a237 100644 --- a/source/tests/test_init_frz_model_se_a_type.py +++ b/source/tests/test_init_frz_model_se_a_type.py @@ -3,31 +3,17 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) - -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - tf, -) -from deepmd.train.run_options import ( - RunOptions, -) -from deepmd.train.trainer import ( - DPTrainer, -) -from deepmd.utils.argcheck import ( - normalize, -) -from deepmd.utils.compat import ( - update_deepmd_input, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) +from common import j_loader +from common import run_dp +from common import tests_path + +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.train.run_options import RunOptions +from deepmd.train.trainer import DPTrainer +from deepmd.utils.argcheck import normalize +from deepmd.utils.compat import update_deepmd_input +from deepmd.utils.data_system import DeepmdDataSystem if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_init_frz_model_se_atten.py b/source/tests/test_init_frz_model_se_atten.py index 86a4fd86b9..3c5bb940b7 100644 --- a/source/tests/test_init_frz_model_se_atten.py +++ b/source/tests/test_init_frz_model_se_atten.py @@ -3,32 +3,18 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) +from common import j_loader +from common import run_dp +from common import tests_path from packaging.version import parse as parse_version -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - tf, -) -from deepmd.train.run_options import ( - RunOptions, -) -from deepmd.train.trainer import ( - DPTrainer, -) -from deepmd.utils.argcheck import ( - normalize, -) -from deepmd.utils.compat import ( - update_deepmd_input, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.train.run_options import RunOptions +from deepmd.train.trainer import DPTrainer +from deepmd.utils.argcheck import normalize +from deepmd.utils.compat import update_deepmd_input +from deepmd.utils.data_system import DeepmdDataSystem if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_init_frz_model_se_r.py b/source/tests/test_init_frz_model_se_r.py index 04fb62d45d..0c312e9ded 100644 --- a/source/tests/test_init_frz_model_se_r.py +++ b/source/tests/test_init_frz_model_se_r.py @@ -3,31 +3,17 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) - -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - tf, -) -from deepmd.train.run_options import ( - RunOptions, -) -from deepmd.train.trainer import ( - DPTrainer, -) -from deepmd.utils.argcheck import ( - normalize, -) -from deepmd.utils.compat import ( - update_deepmd_input, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) +from common import j_loader +from common import run_dp +from common import tests_path + +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.train.run_options import RunOptions +from deepmd.train.trainer import DPTrainer +from deepmd.utils.argcheck import normalize +from deepmd.utils.compat import update_deepmd_input +from deepmd.utils.data_system import DeepmdDataSystem if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_init_frz_model_spin.py b/source/tests/test_init_frz_model_spin.py index 18fcb71773..f17a1c3079 100644 --- a/source/tests/test_init_frz_model_spin.py +++ b/source/tests/test_init_frz_model_spin.py @@ -3,31 +3,17 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) - -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - tf, -) -from deepmd.train.run_options import ( - RunOptions, -) -from deepmd.train.trainer import ( - DPTrainer, -) -from deepmd.utils.argcheck import ( - normalize, -) -from deepmd.utils.compat import ( - update_deepmd_input, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) +from common import j_loader +from common import run_dp +from common import tests_path + +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import tf +from deepmd.train.run_options import RunOptions +from deepmd.train.trainer import DPTrainer +from deepmd.utils.argcheck import normalize +from deepmd.utils.compat import update_deepmd_input +from deepmd.utils.data_system import DeepmdDataSystem if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_lammps.py b/source/tests/test_lammps.py index c1a8036a7f..341b70fdfd 100644 --- a/source/tests/test_lammps.py +++ b/source/tests/test_lammps.py @@ -1,13 +1,9 @@ import os import subprocess import unittest -from pathlib import ( - Path, -) +from pathlib import Path -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) +from deepmd.utils.convert import convert_pbtxt_to_pb @unittest.skipIf( diff --git a/source/tests/test_layer_name.py b/source/tests/test_layer_name.py index db7bb18d2a..9f3d412ffa 100644 --- a/source/tests/test_layer_name.py +++ b/source/tests/test_layer_name.py @@ -1,27 +1,15 @@ import numpy as np -from common import ( - DataSystem, - del_data, - gen_data, - j_loader, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - DipoleFittingSeA, - EnerFitting, -) -from deepmd.model import ( - MultiModel, -) +from common import DataSystem +from common import del_data +from common import gen_data +from common import j_loader + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import DipoleFittingSeA +from deepmd.fit import EnerFitting +from deepmd.model import MultiModel GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_mixed_prec_training.py b/source/tests/test_mixed_prec_training.py index 4becf9464b..f710f793f4 100644 --- a/source/tests/test_mixed_prec_training.py +++ b/source/tests/test_mixed_prec_training.py @@ -6,18 +6,12 @@ import numpy as np # from deepmd.entrypoints.compress import compress -from common import ( - j_loader, - run_dp, - tests_path, -) -from packaging.version import ( - Version, -) +from common import j_loader +from common import run_dp +from common import tests_path +from packaging.version import Version -from deepmd.env import ( - TF_VERSION, -) +from deepmd.env import TF_VERSION def _file_delete(file): diff --git a/source/tests/test_model_compression_se_a.py b/source/tests/test_model_compression_se_a.py index dcd42184ca..9e66f419ff 100644 --- a/source/tests/test_model_compression_se_a.py +++ b/source/tests/test_model_compression_se_a.py @@ -6,18 +6,12 @@ import numpy as np # from deepmd.entrypoints.compress import compress -from common import ( - j_loader, - run_dp, - tests_path, -) - -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.infer import ( - DeepPot, -) +from common import j_loader +from common import run_dp +from common import tests_path + +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.infer import DeepPot if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 @@ -377,13 +371,9 @@ def test_1frame_atm(self): np.testing.assert_almost_equal(vv0, vv1, default_places) def test_ase(self): - from ase import ( - Atoms, - ) + from ase import Atoms - from deepmd.calculator import ( - DP, - ) + from deepmd.calculator import DP water0 = Atoms( "OHHOHH", diff --git a/source/tests/test_model_compression_se_a_type_one_side_exclude_types.py b/source/tests/test_model_compression_se_a_type_one_side_exclude_types.py index c39c6470ed..6cf332f42d 100644 --- a/source/tests/test_model_compression_se_a_type_one_side_exclude_types.py +++ b/source/tests/test_model_compression_se_a_type_one_side_exclude_types.py @@ -6,18 +6,12 @@ import numpy as np # from deepmd.entrypoints.compress import compress -from common import ( - j_loader, - run_dp, - tests_path, -) - -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.infer import ( - DeepPot, -) +from common import j_loader +from common import run_dp +from common import tests_path + +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.infer import DeepPot if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_model_compression_se_r.py b/source/tests/test_model_compression_se_r.py index f85546b7ee..3751ff09d2 100644 --- a/source/tests/test_model_compression_se_r.py +++ b/source/tests/test_model_compression_se_r.py @@ -6,18 +6,12 @@ import numpy as np # from deepmd.entrypoints.compress import compress -from common import ( - j_loader, - run_dp, - tests_path, -) - -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.infer import ( - DeepPot, -) +from common import j_loader +from common import run_dp +from common import tests_path + +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.infer import DeepPot if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 @@ -385,13 +379,9 @@ def test_1frame_atm(self): np.testing.assert_almost_equal(vv0, vv1, default_places) def test_ase(self): - from ase import ( - Atoms, - ) + from ase import Atoms - from deepmd.calculator import ( - DP, - ) + from deepmd.calculator import DP water0 = Atoms( "OHHOHH", diff --git a/source/tests/test_model_compression_se_t.py b/source/tests/test_model_compression_se_t.py index 0e33430158..fc6b0e3f18 100644 --- a/source/tests/test_model_compression_se_t.py +++ b/source/tests/test_model_compression_se_t.py @@ -6,18 +6,12 @@ import numpy as np # from deepmd.entrypoints.compress import compress -from common import ( - j_loader, - run_dp, - tests_path, -) - -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.infer import ( - DeepPot, -) +from common import j_loader +from common import run_dp +from common import tests_path + +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.infer import DeepPot if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 @@ -407,13 +401,9 @@ def test_1frame_atm(self): np.testing.assert_almost_equal(vv0, vv1, default_places) def test_ase(self): - from ase import ( - Atoms, - ) + from ase import Atoms - from deepmd.calculator import ( - DP, - ) + from deepmd.calculator import DP water0 = Atoms( "OHHOHH", diff --git a/source/tests/test_model_devi.py b/source/tests/test_model_devi.py index 20dd57386b..5091648d6c 100644 --- a/source/tests/test_model_devi.py +++ b/source/tests/test_model_devi.py @@ -4,24 +4,16 @@ import numpy as np -from deepmd.infer import ( - DeepPotential, - calc_model_devi, -) -from deepmd.infer.model_devi import ( - make_model_devi, -) +from deepmd.infer import DeepPotential +from deepmd.infer import calc_model_devi +from deepmd.infer.model_devi import make_model_devi sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) -from common import ( - del_data, - gen_data, - tests_path, -) +from common import del_data +from common import gen_data +from common import tests_path -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) +from deepmd.utils.convert import convert_pbtxt_to_pb class TestMakeModelDevi(unittest.TestCase): diff --git a/source/tests/test_model_devi_mix.py b/source/tests/test_model_devi_mix.py index 4dcb34bd48..d3c166c935 100644 --- a/source/tests/test_model_devi_mix.py +++ b/source/tests/test_model_devi_mix.py @@ -4,28 +4,18 @@ import numpy as np -from deepmd.infer import ( - DeepPotential, - calc_model_devi, -) -from deepmd.infer.model_devi import ( - make_model_devi, -) +from deepmd.infer import DeepPotential +from deepmd.infer import calc_model_devi +from deepmd.infer.model_devi import make_model_devi sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) -from common import ( - del_data, - gen_data, - tests_path, -) +from common import del_data +from common import gen_data +from common import tests_path from packaging.version import parse as parse_version -from deepmd.env import ( - tf, -) -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) +from deepmd.env import tf +from deepmd.utils.convert import convert_pbtxt_to_pb @unittest.skipIf( diff --git a/source/tests/test_model_dos.py b/source/tests/test_model_dos.py index a6c880046e..f267e3d5a3 100644 --- a/source/tests/test_model_dos.py +++ b/source/tests/test_model_dos.py @@ -1,26 +1,14 @@ import numpy as np -from common import ( - DataSystem, - del_data, - gen_data, - j_loader, -) +from common import DataSystem +from common import del_data +from common import gen_data +from common import j_loader -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - DOSFitting, -) -from deepmd.model import ( - DOSModel, -) +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import DOSFitting +from deepmd.model import DOSModel GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_model_loc_frame.py b/source/tests/test_model_loc_frame.py index f33c571ed3..68d53badaa 100644 --- a/source/tests/test_model_loc_frame.py +++ b/source/tests/test_model_loc_frame.py @@ -1,25 +1,13 @@ import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) +from common import DataSystem +from common import gen_data +from common import j_loader -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptLocFrame, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model import ( - EnerModel, -) +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptLocFrame +from deepmd.env import tf +from deepmd.fit import EnerFitting +from deepmd.model import EnerModel GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_model_multi.py b/source/tests/test_model_multi.py index faa682c3a1..bdd21c28e2 100644 --- a/source/tests/test_model_multi.py +++ b/source/tests/test_model_multi.py @@ -1,29 +1,17 @@ import numpy as np -from common import ( - DataSystem, - del_data, - finite_difference, - gen_data, - j_loader, - strerch_box, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - DipoleFittingSeA, - EnerFitting, -) -from deepmd.model import ( - MultiModel, -) +from common import DataSystem +from common import del_data +from common import finite_difference +from common import gen_data +from common import j_loader +from common import strerch_box + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import DipoleFittingSeA +from deepmd.fit import EnerFitting +from deepmd.model import MultiModel GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_model_se_a.py b/source/tests/test_model_se_a.py index ec88aceac2..0ac359c00f 100644 --- a/source/tests/test_model_se_a.py +++ b/source/tests/test_model_se_a.py @@ -1,30 +1,16 @@ import dpdata import numpy as np -from common import ( - DataSystem, - del_data, - gen_data, - j_loader, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model import ( - EnerModel, -) -from deepmd.utils.type_embed import ( - TypeEmbedNet, -) +from common import DataSystem +from common import del_data +from common import gen_data +from common import j_loader + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import EnerFitting +from deepmd.model import EnerModel +from deepmd.utils.type_embed import TypeEmbedNet GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_model_se_a_aparam.py b/source/tests/test_model_se_a_aparam.py index 1745ffb642..b183e2593f 100644 --- a/source/tests/test_model_se_a_aparam.py +++ b/source/tests/test_model_se_a_aparam.py @@ -1,25 +1,13 @@ import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) +from common import DataSystem +from common import gen_data +from common import j_loader -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model import ( - EnerModel, -) +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import EnerFitting +from deepmd.model import EnerModel GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_model_se_a_ebd.py b/source/tests/test_model_se_a_ebd.py index 34832e2b5b..52b67135f4 100644 --- a/source/tests/test_model_se_a_ebd.py +++ b/source/tests/test_model_se_a_ebd.py @@ -1,25 +1,13 @@ import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor.se_a_ebd import ( - DescrptSeAEbd, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model import ( - EnerModel, -) +from common import DataSystem +from common import gen_data +from common import j_loader + +from deepmd.common import j_must_have +from deepmd.descriptor.se_a_ebd import DescrptSeAEbd +from deepmd.env import tf +from deepmd.fit import EnerFitting +from deepmd.model import EnerModel GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_model_se_a_fparam.py b/source/tests/test_model_se_a_fparam.py index bd3e3c0c20..e553f07045 100644 --- a/source/tests/test_model_se_a_fparam.py +++ b/source/tests/test_model_se_a_fparam.py @@ -1,25 +1,13 @@ import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model import ( - EnerModel, -) +from common import DataSystem +from common import gen_data +from common import j_loader + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import EnerFitting +from deepmd.model import EnerModel GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_model_se_a_srtab.py b/source/tests/test_model_se_a_srtab.py index 36bc955f0a..af3c0c96b6 100644 --- a/source/tests/test_model_se_a_srtab.py +++ b/source/tests/test_model_se_a_srtab.py @@ -1,27 +1,15 @@ import os import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model import ( - EnerModel, -) +from common import DataSystem +from common import gen_data +from common import j_loader + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import EnerFitting +from deepmd.model import EnerModel GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_model_se_a_type.py b/source/tests/test_model_se_a_type.py index b7e72eb3aa..4a3f6b6c02 100644 --- a/source/tests/test_model_se_a_type.py +++ b/source/tests/test_model_se_a_type.py @@ -1,28 +1,14 @@ import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model import ( - EnerModel, -) -from deepmd.utils.type_embed import ( - TypeEmbedNet, -) +from common import DataSystem +from common import gen_data +from common import j_loader + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import EnerFitting +from deepmd.model import EnerModel +from deepmd.utils.type_embed import TypeEmbedNet GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_model_se_atten.py b/source/tests/test_model_se_atten.py index b473c43c10..ce44acc886 100644 --- a/source/tests/test_model_se_atten.py +++ b/source/tests/test_model_se_atten.py @@ -1,31 +1,17 @@ import unittest import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) +from common import DataSystem +from common import gen_data +from common import j_loader from packaging.version import parse as parse_version -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeAtten, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model import ( - EnerModel, -) -from deepmd.utils.type_embed import ( - TypeEmbedNet, -) +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeAtten +from deepmd.env import tf +from deepmd.fit import EnerFitting +from deepmd.model import EnerModel +from deepmd.utils.type_embed import TypeEmbedNet GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_model_se_r.py b/source/tests/test_model_se_r.py index 15771c9ec8..bab92b8ac5 100644 --- a/source/tests/test_model_se_r.py +++ b/source/tests/test_model_se_r.py @@ -1,25 +1,13 @@ import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeR, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model import ( - EnerModel, -) +from common import DataSystem +from common import gen_data +from common import j_loader + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeR +from deepmd.env import tf +from deepmd.fit import EnerFitting +from deepmd.model import EnerModel GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_model_se_t.py b/source/tests/test_model_se_t.py index 108baea3fc..8bd331e2c5 100644 --- a/source/tests/test_model_se_t.py +++ b/source/tests/test_model_se_t.py @@ -1,25 +1,13 @@ import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeT, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model import ( - EnerModel, -) +from common import DataSystem +from common import gen_data +from common import j_loader + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeT +from deepmd.env import tf +from deepmd.fit import EnerFitting +from deepmd.model import EnerModel GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_model_spin.py b/source/tests/test_model_spin.py index 0bd2856552..ba1e13b0f2 100644 --- a/source/tests/test_model_spin.py +++ b/source/tests/test_model_spin.py @@ -1,31 +1,17 @@ import unittest import numpy as np -from common import ( - DataSystem, - del_data, - gen_data, - j_loader, -) +from common import DataSystem +from common import del_data +from common import gen_data +from common import j_loader -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - EnerFitting, -) -from deepmd.model import ( - EnerModel, -) -from deepmd.utils.spin import ( - Spin, -) +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import EnerFitting +from deepmd.model import EnerModel +from deepmd.utils.spin import Spin GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_neighbor_stat.py b/source/tests/test_neighbor_stat.py index 64f314759f..7cba930c57 100644 --- a/source/tests/test_neighbor_stat.py +++ b/source/tests/test_neighbor_stat.py @@ -4,9 +4,7 @@ import dpdata import numpy as np -from deepmd.entrypoints.neighbor_stat import ( - neighbor_stat, -) +from deepmd.entrypoints.neighbor_stat import neighbor_stat def gen_sys(nframes): diff --git a/source/tests/test_nvnmd_entrypoints.py b/source/tests/test_nvnmd_entrypoints.py index 9070cad478..752aef452b 100644 --- a/source/tests/test_nvnmd_entrypoints.py +++ b/source/tests/test_nvnmd_entrypoints.py @@ -2,37 +2,19 @@ import unittest import numpy as np -from common import ( - tests_path, -) +from common import tests_path -from deepmd.env import ( - tf, -) -from deepmd.nvnmd.data.data import ( - jdata_deepmd_input, -) -from deepmd.nvnmd.entrypoints.freeze import ( - save_weight, -) -from deepmd.nvnmd.entrypoints.mapt import ( - mapt, -) -from deepmd.nvnmd.entrypoints.train import ( - normalized_input, - normalized_input_qnn, -) -from deepmd.nvnmd.entrypoints.wrap import ( - wrap, -) -from deepmd.nvnmd.utils.config import ( - nvnmd_cfg, -) -from deepmd.nvnmd.utils.fio import ( - FioBin, - FioJsonDic, - FioNpyDic, -) +from deepmd.env import tf +from deepmd.nvnmd.data.data import jdata_deepmd_input +from deepmd.nvnmd.entrypoints.freeze import save_weight +from deepmd.nvnmd.entrypoints.mapt import mapt +from deepmd.nvnmd.entrypoints.train import normalized_input +from deepmd.nvnmd.entrypoints.train import normalized_input_qnn +from deepmd.nvnmd.entrypoints.wrap import wrap +from deepmd.nvnmd.utils.config import nvnmd_cfg +from deepmd.nvnmd.utils.fio import FioBin +from deepmd.nvnmd.utils.fio import FioJsonDic +from deepmd.nvnmd.utils.fio import FioNpyDic class TestNvnmdFreeze(tf.test.TestCase): diff --git a/source/tests/test_nvnmd_op.py b/source/tests/test_nvnmd_op.py index 1f54da29c5..b99fb64a37 100644 --- a/source/tests/test_nvnmd_op.py +++ b/source/tests/test_nvnmd_op.py @@ -2,15 +2,11 @@ import unittest import numpy as np -from common import ( - tests_path, -) - -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - op_module, - tf, -) +from common import tests_path + +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf class TestOpAddFltNvnmd(tf.test.TestCase): diff --git a/source/tests/test_nvnmd_se_a.py b/source/tests/test_nvnmd_se_a.py index fcc96ad811..351cb91c36 100644 --- a/source/tests/test_nvnmd_se_a.py +++ b/source/tests/test_nvnmd_se_a.py @@ -2,32 +2,20 @@ import unittest import numpy as np -from common import ( - j_loader, -) +from common import j_loader -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 # -from common import ( - tests_path, -) +from common import tests_path -from deepmd.nvnmd.data.data import ( - jdata_deepmd_input, -) -from deepmd.nvnmd.utils.config import ( - nvnmd_cfg, -) +from deepmd.nvnmd.data.data import jdata_deepmd_input +from deepmd.nvnmd.utils.config import nvnmd_cfg class TestModel(tf.test.TestCase): diff --git a/source/tests/test_nvnmd_utils.py b/source/tests/test_nvnmd_utils.py index eafd1b4d6c..629a1cc8c8 100644 --- a/source/tests/test_nvnmd_utils.py +++ b/source/tests/test_nvnmd_utils.py @@ -3,18 +3,10 @@ import numpy as np -from deepmd.env import ( - tf, -) -from deepmd.nvnmd.data.data import ( - jdata_deepmd_input, -) -from deepmd.nvnmd.utils.config import ( - nvnmd_cfg, -) -from deepmd.nvnmd.utils.network import ( - one_layer, -) +from deepmd.env import tf +from deepmd.nvnmd.data.data import jdata_deepmd_input +from deepmd.nvnmd.utils.config import nvnmd_cfg +from deepmd.nvnmd.utils.network import one_layer class TestNvnmdNetwork(tf.test.TestCase): diff --git a/source/tests/test_parallel_training.py b/source/tests/test_parallel_training.py index e2e78bde99..72dcfb6be9 100644 --- a/source/tests/test_parallel_training.py +++ b/source/tests/test_parallel_training.py @@ -2,13 +2,9 @@ import subprocess as sp import unittest -from common import ( - tests_path, -) +from common import tests_path -from deepmd.cluster.local import ( - get_gpus, -) +from deepmd.cluster.local import get_gpus class TestSingleMachine(unittest.TestCase): diff --git a/source/tests/test_polar_se_a.py b/source/tests/test_polar_se_a.py index 30834431c1..22950d610e 100644 --- a/source/tests/test_polar_se_a.py +++ b/source/tests/test_polar_se_a.py @@ -1,27 +1,15 @@ import numpy as np -from common import ( - DataSystem, - finite_difference, - gen_data, - j_loader, - strerch_box, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - PolarFittingSeA, -) -from deepmd.model import ( - PolarModel, -) +from common import DataSystem +from common import finite_difference +from common import gen_data +from common import j_loader +from common import strerch_box + +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import PolarFittingSeA +from deepmd.model import PolarModel GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_polar_se_a_tebd.py b/source/tests/test_polar_se_a_tebd.py index a60b86a5ea..c0f5a6a6fe 100644 --- a/source/tests/test_polar_se_a_tebd.py +++ b/source/tests/test_polar_se_a_tebd.py @@ -1,33 +1,19 @@ import unittest import numpy as np -from common import ( - DataSystem, - finite_difference, - gen_data, - j_loader, - strerch_box, -) +from common import DataSystem +from common import finite_difference +from common import gen_data +from common import j_loader +from common import strerch_box from packaging.version import parse as parse_version -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - DescrptSeA, -) -from deepmd.env import ( - tf, -) -from deepmd.fit import ( - PolarFittingSeA, -) -from deepmd.model import ( - PolarModel, -) -from deepmd.utils.type_embed import ( - TypeEmbedNet, -) +from deepmd.common import j_must_have +from deepmd.descriptor import DescrptSeA +from deepmd.env import tf +from deepmd.fit import PolarFittingSeA +from deepmd.model import PolarModel +from deepmd.utils.type_embed import TypeEmbedNet GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_prod_env_mat.py b/source/tests/test_prod_env_mat.py index 4dd3b0e52e..59db7881a1 100644 --- a/source/tests/test_prod_env_mat.py +++ b/source/tests/test_prod_env_mat.py @@ -1,11 +1,9 @@ import numpy as np -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf class TestProdEnvMat(tf.test.TestCase): diff --git a/source/tests/test_prod_force.py b/source/tests/test_prod_force.py index 880a849605..9b1b7f9f20 100644 --- a/source/tests/test_prod_force.py +++ b/source/tests/test_prod_force.py @@ -3,11 +3,9 @@ import numpy as np -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf class TestProdForce(tf.test.TestCase): diff --git a/source/tests/test_prod_force_grad.py b/source/tests/test_prod_force_grad.py index bfe4f5d12c..0c649440ab 100644 --- a/source/tests/test_prod_force_grad.py +++ b/source/tests/test_prod_force_grad.py @@ -1,10 +1,8 @@ import numpy as np -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - op_grads_module, - tf, -) +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_grads_module +from deepmd.env import tf class TestProdForceGrad(tf.test.TestCase): diff --git a/source/tests/test_prod_virial.py b/source/tests/test_prod_virial.py index d1f7431048..8f8682ea68 100644 --- a/source/tests/test_prod_virial.py +++ b/source/tests/test_prod_virial.py @@ -1,10 +1,8 @@ import numpy as np -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - op_module, - tf, -) +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_module +from deepmd.env import tf class TestProdVirial(tf.test.TestCase): diff --git a/source/tests/test_prod_virial_grad.py b/source/tests/test_prod_virial_grad.py index ebf019b620..5adfff0ea2 100644 --- a/source/tests/test_prod_virial_grad.py +++ b/source/tests/test_prod_virial_grad.py @@ -1,10 +1,8 @@ import numpy as np -from deepmd.env import ( - GLOBAL_TF_FLOAT_PRECISION, - op_grads_module, - tf, -) +from deepmd.env import GLOBAL_TF_FLOAT_PRECISION +from deepmd.env import op_grads_module +from deepmd.env import tf class TestProdVirialGrad(tf.test.TestCase): diff --git a/source/tests/test_sel_idx.py b/source/tests/test_sel_idx.py index 303897d3b9..300f19b689 100644 --- a/source/tests/test_sel_idx.py +++ b/source/tests/test_sel_idx.py @@ -2,9 +2,7 @@ import numpy as np -from deepmd.common import ( - select_idx_map, -) +from deepmd.common import select_idx_map class TestSelIdx(unittest.TestCase): diff --git a/source/tests/test_tab_nonsmth.py b/source/tests/test_tab_nonsmth.py index 5e042f7225..9394420604 100644 --- a/source/tests/test_tab_nonsmth.py +++ b/source/tests/test_tab_nonsmth.py @@ -2,26 +2,18 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) -from test_descrpt_nonsmth import ( - Inter, -) +from common import Data +from common import force_dw_test +from common import force_test +from common import virial_dw_test +from common import virial_test +from test_descrpt_nonsmth import Inter # load grad of force module import deepmd.op # noqa: F401 -from deepmd.env import ( - op_module, - tf, -) -from deepmd.utils.pair_tab import ( - PairTab, -) +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.utils.pair_tab import PairTab def _make_tab(ntype): diff --git a/source/tests/test_tab_smooth.py b/source/tests/test_tab_smooth.py index 56b0f269c4..32e5c1464b 100644 --- a/source/tests/test_tab_smooth.py +++ b/source/tests/test_tab_smooth.py @@ -2,25 +2,17 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) -from test_descrpt_smooth import ( - Inter, -) +from common import Data +from common import force_dw_test +from common import force_test +from common import virial_dw_test +from common import virial_test +from test_descrpt_smooth import Inter # load grad of force module -from deepmd.env import ( - op_module, - tf, -) -from deepmd.utils.pair_tab import ( - PairTab, -) +from deepmd.env import op_module +from deepmd.env import tf +from deepmd.utils.pair_tab import PairTab def _make_tab(ntype): diff --git a/source/tests/test_tabulate.py b/source/tests/test_tabulate.py index 845fb1031e..d689c9828c 100644 --- a/source/tests/test_tabulate.py +++ b/source/tests/test_tabulate.py @@ -2,13 +2,9 @@ import numpy as np -from deepmd.common import ( - gelu, -) -from deepmd.env import ( - op_module, - tf, -) +from deepmd.common import gelu +from deepmd.env import op_module +from deepmd.env import tf # Now just test some OPs utilized by DPTabulate sourced in /opt/deepmd-kit/source/op/unaggregated_grad.cc diff --git a/source/tests/test_train.py b/source/tests/test_train.py index 7f6617a5f1..4ef724afb8 100644 --- a/source/tests/test_train.py +++ b/source/tests/test_train.py @@ -1,15 +1,11 @@ import unittest -from unittest.mock import ( - patch, -) +from unittest.mock import patch -from deepmd.entrypoints.train import ( - parse_auto_sel, - parse_auto_sel_ratio, - update_one_sel, - update_sel, - wrap_up_4, -) +from deepmd.entrypoints.train import parse_auto_sel +from deepmd.entrypoints.train import parse_auto_sel_ratio +from deepmd.entrypoints.train import update_one_sel +from deepmd.entrypoints.train import update_sel +from deepmd.entrypoints.train import wrap_up_4 class TestTrain(unittest.TestCase): diff --git a/source/tests/test_transfer.py b/source/tests/test_transfer.py index 14f88c17dc..b2e879e9da 100644 --- a/source/tests/test_transfer.py +++ b/source/tests/test_transfer.py @@ -3,20 +3,12 @@ import unittest import numpy as np -from common import ( - run_dp, - tests_path, -) +from common import run_dp +from common import tests_path -from deepmd.env import ( - GLOBAL_NP_FLOAT_PRECISION, -) -from deepmd.infer import ( - DeepPot, -) -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) +from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.infer import DeepPot +from deepmd.utils.convert import convert_pbtxt_to_pb if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 diff --git a/source/tests/test_type_embed.py b/source/tests/test_type_embed.py index 87718c1280..a18881bc2f 100644 --- a/source/tests/test_type_embed.py +++ b/source/tests/test_type_embed.py @@ -1,12 +1,8 @@ import numpy as np -from deepmd.env import ( - tf, -) -from deepmd.utils.type_embed import ( - TypeEmbedNet, - embed_atom_type, -) +from deepmd.env import tf +from deepmd.utils.type_embed import TypeEmbedNet +from deepmd.utils.type_embed import embed_atom_type class TestTypeEbd(tf.test.TestCase): diff --git a/source/tests/test_type_one_side.py b/source/tests/test_type_one_side.py index 2f6ff81e76..ff4bd2d031 100644 --- a/source/tests/test_type_one_side.py +++ b/source/tests/test_type_one_side.py @@ -1,19 +1,11 @@ import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) - -from deepmd.common import ( - j_must_have, -) -from deepmd.descriptor import ( - Descriptor, -) -from deepmd.env import ( - tf, -) +from common import DataSystem +from common import gen_data +from common import j_loader + +from deepmd.common import j_must_have +from deepmd.descriptor import Descriptor +from deepmd.env import tf GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 diff --git a/source/tests/test_virtual_type.py b/source/tests/test_virtual_type.py index 98ab84cf93..29b76da614 100644 --- a/source/tests/test_virtual_type.py +++ b/source/tests/test_virtual_type.py @@ -3,27 +3,15 @@ import unittest import numpy as np -from common import ( - gen_data, - j_loader, - tests_path, -) +from common import gen_data +from common import j_loader +from common import tests_path -from deepmd.common import ( - j_must_have, -) -from deepmd.infer import ( - DeepPot, -) -from deepmd.utils.convert import ( - convert_pbtxt_to_pb, -) -from deepmd.utils.data_system import ( - DeepmdDataSystem, -) -from deepmd.utils.neighbor_stat import ( - NeighborStat, -) +from deepmd.common import j_must_have +from deepmd.infer import DeepPot +from deepmd.utils.convert import convert_pbtxt_to_pb +from deepmd.utils.data_system import DeepmdDataSystem +from deepmd.utils.neighbor_stat import NeighborStat class TestVirtualType(unittest.TestCase):