diff --git a/backend/dp_backend.py b/backend/dp_backend.py index 6fc5676c01..97fa1578c7 100644 --- a/backend/dp_backend.py +++ b/backend/dp_backend.py @@ -1,7 +1,11 @@ """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 163f91d798..52c7fc5286 100644 --- a/backend/find_tensorflow.py +++ b/backend/find_tensorflow.py @@ -1,15 +1,27 @@ 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 -from typing import Optional -from typing import Tuple -from typing import 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, + Optional, + Tuple, + 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 5568d7196a..6c97771bec 100644 --- a/data/json/json2yaml.py +++ b/data/json/json2yaml.py @@ -2,8 +2,12 @@ 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 a9138c5642..d96d7eb4a4 100644 --- a/deepmd/__init__.py +++ b/deepmd/__init__.py @@ -1,29 +1,41 @@ """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 -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 +from . import ( + cluster, + descriptor, + fit, + loss, + nvnmd, + utils, +) +from .env import ( + set_mkl, +) +from .infer import ( + DeepEval, + 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 09e38228fd..8e3011bc7b 100644 --- a/deepmd/__main__.py +++ b/deepmd/__main__.py @@ -1,6 +1,8 @@ """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 d878266468..4777bc80bc 100644 --- a/deepmd/calculator.py +++ b/deepmd/calculator.py @@ -1,20 +1,30 @@ """ASE calculator interface module.""" -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 +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, +) 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 c9865ac429..4cba0c10b9 100644 --- a/deepmd/cluster/__init__.py +++ b/deepmd/cluster/__init__.py @@ -1,9 +1,11 @@ """Module that reads node resources, auto detects if running local or on SLURM.""" import os -from typing import List -from typing import Optional -from typing import Tuple +from typing import ( + List, + Optional, + 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 37379b9739..8ad9a83659 100644 --- a/deepmd/cluster/local.py +++ b/deepmd/cluster/local.py @@ -3,11 +3,15 @@ import socket import subprocess as sp import sys -from typing import List -from typing import Optional -from typing import Tuple - -from deepmd.env import tf +from typing import ( + List, + Optional, + Tuple, +) + +from deepmd.env import ( + tf, +) __all__ = ["get_gpus", "get_resource"] diff --git a/deepmd/cluster/slurm.py b/deepmd/cluster/slurm.py index 60e7b68a9e..2be6b438f2 100644 --- a/deepmd/cluster/slurm.py +++ b/deepmd/cluster/slurm.py @@ -6,13 +6,17 @@ """ import os -from typing import List -from typing import Optional -from typing import Tuple +from typing import ( + List, + Optional, + Tuple, +) import hostlist -from deepmd.cluster import local +from deepmd.cluster import ( + local, +) __all__ = ["get_resource"] diff --git a/deepmd/common.py b/deepmd/common.py index 0f22318ae8..449729c556 100644 --- a/deepmd/common.py +++ b/deepmd/common.py @@ -26,7 +26,6 @@ from deepmd.env import ( GLOBAL_NP_FLOAT_PRECISION, GLOBAL_PD_FLOAT_PRECISION, - GLOBAL_TF_FLOAT_PRECISION, op_module, paddle, tf, diff --git a/deepmd/descriptor/__init__.py b/deepmd/descriptor/__init__.py index 9a14bdb185..3b55a4f97a 100644 --- a/deepmd/descriptor/__init__.py +++ b/deepmd/descriptor/__init__.py @@ -1,14 +1,34 @@ -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 +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, +) __all__ = [ "Descriptor", diff --git a/deepmd/descriptor/descriptor.py b/deepmd/descriptor/descriptor.py index 59188a9ce0..3542918cb3 100644 --- a/deepmd/descriptor/descriptor.py +++ b/deepmd/descriptor/descriptor.py @@ -1,17 +1,25 @@ -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 +from abc import ( + abstractmethod, +) +from typing import ( + Any, + Callable, + Dict, + List, + Optional, + Tuple, +) import numpy as np -from deepmd.env import GLOBAL_TF_FLOAT_PRECISION -from deepmd.env import tf -from deepmd.utils import Plugin -from deepmd.utils import PluginVariant +from deepmd.env import ( + GLOBAL_TF_FLOAT_PRECISION, + tf, +) +from deepmd.utils import ( + Plugin, + PluginVariant, +) class Descriptor(PluginVariant): diff --git a/deepmd/descriptor/hybrid.py b/deepmd/descriptor/hybrid.py index c89ceb5c44..e1ddf5f2e9 100644 --- a/deepmd/descriptor/hybrid.py +++ b/deepmd/descriptor/hybrid.py @@ -1,12 +1,18 @@ -from typing import List -from typing import Optional -from typing import Tuple +from typing import ( + List, + Optional, + Tuple, +) import numpy as np -from deepmd.env import GLOBAL_TF_FLOAT_PRECISION -from deepmd.env import tf -from deepmd.utils.spin import Spin +from deepmd.env import ( + GLOBAL_TF_FLOAT_PRECISION, + tf, +) +from deepmd.utils.spin import ( + Spin, +) # from deepmd.descriptor import DescrptLocFrame # from deepmd.descriptor import DescrptSeA @@ -14,7 +20,9 @@ # 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 f268208416..dd99f7fb57 100644 --- a/deepmd/descriptor/loc_frame.py +++ b/deepmd/descriptor/loc_frame.py @@ -1,18 +1,28 @@ -from typing import List -from typing import Optional -from typing import Tuple +from typing import ( + List, + Optional, + Tuple, +) import numpy as np -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 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 .descriptor import Descriptor +from .descriptor import ( + Descriptor, +) @Descriptor.register("loc_frame") diff --git a/deepmd/descriptor/se.py b/deepmd/descriptor/se.py index 26dcc4d5f1..242ee5425d 100644 --- a/deepmd/descriptor/se.py +++ b/deepmd/descriptor/se.py @@ -1,10 +1,18 @@ -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 +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, +) class DescrptSe(Descriptor): diff --git a/deepmd/descriptor/se_a_ebd.py b/deepmd/descriptor/se_a_ebd.py index 0b009af24d..e0684403e1 100644 --- a/deepmd/descriptor/se_a_ebd.py +++ b/deepmd/descriptor/se_a_ebd.py @@ -1,17 +1,29 @@ -from typing import List -from typing import Optional +from typing import ( + List, + Optional, +) import numpy as np -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 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 .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 d050966175..0dbad403f4 100644 --- a/deepmd/descriptor/se_a_ef.py +++ b/deepmd/descriptor/se_a_ef.py @@ -1,19 +1,31 @@ -from typing import List -from typing import Optional -from typing import Tuple +from typing import ( + List, + Optional, + Tuple, +) import numpy as np -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 +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, +) @Descriptor.register("se_a_ef") diff --git a/deepmd/descriptor/se_a_mask.py b/deepmd/descriptor/se_a_mask.py index e1f88629e4..93256e3910 100644 --- a/deepmd/descriptor/se_a_mask.py +++ b/deepmd/descriptor/se_a_mask.py @@ -1,23 +1,35 @@ import warnings -from typing import Any -from typing import Dict -from typing import List -from typing import Optional -from typing import Tuple +from typing import ( + Any, + Dict, + List, + Optional, + Tuple, +) import numpy as np -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 +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, +) @Descriptor.register("se_a_mask") diff --git a/deepmd/descriptor/se_atten.py b/deepmd/descriptor/se_atten.py index 2643467f83..b113e5c994 100644 --- a/deepmd/descriptor/se_atten.py +++ b/deepmd/descriptor/se_atten.py @@ -1,25 +1,43 @@ import warnings -from typing import List -from typing import Optional -from typing import Tuple +from typing import ( + List, + Optional, + 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 -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 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 .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 b2afe76be1..7ef5f47347 100644 --- a/deepmd/descriptor/se_r.py +++ b/deepmd/descriptor/se_r.py @@ -1,26 +1,46 @@ -from typing import List -from typing import Optional -from typing import Tuple +from typing import ( + List, + Optional, + Tuple, +) import numpy as np -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 +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, +) @Descriptor.register("se_e2_r") diff --git a/deepmd/descriptor/se_t.py b/deepmd/descriptor/se_t.py index d35b68894f..7615275a82 100644 --- a/deepmd/descriptor/se_t.py +++ b/deepmd/descriptor/se_t.py @@ -1,25 +1,43 @@ -from typing import List -from typing import Optional -from typing import Tuple +from typing import ( + List, + Optional, + Tuple, +) import numpy as np -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 +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, +) @Descriptor.register("se_e3") diff --git a/deepmd/entrypoints/__init__.py b/deepmd/entrypoints/__init__.py index 66405f0e0d..fc690daf14 100644 --- a/deepmd/entrypoints/__init__.py +++ b/deepmd/entrypoints/__init__.py @@ -1,17 +1,33 @@ """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 ee5ce3a1e2..a198127d12 100644 --- a/deepmd/entrypoints/compress.py +++ b/deepmd/entrypoints/compress.py @@ -3,22 +3,40 @@ import json import logging import os -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 +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, +) __all__ = ["compress"] diff --git a/deepmd/entrypoints/convert.py b/deepmd/entrypoints/convert.py index dfd12bf4b7..b97c137104 100644 --- a/deepmd/entrypoints/convert.py +++ b/deepmd/entrypoints/convert.py @@ -1,10 +1,12 @@ -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 +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, +) def convert( diff --git a/deepmd/entrypoints/doc.py b/deepmd/entrypoints/doc.py index 42fcca983c..b439c17409 100644 --- a/deepmd/entrypoints/doc.py +++ b/deepmd/entrypoints/doc.py @@ -1,7 +1,9 @@ """Module that prints train input arguments docstrings.""" -from deepmd.utils.argcheck import gen_doc -from deepmd.utils.argcheck import gen_json +from deepmd.utils.argcheck import ( + gen_doc, + gen_json, +) __all__ = ["doc_train_input"] diff --git a/deepmd/entrypoints/ipi.py b/deepmd/entrypoints/ipi.py index 55378975cd..4208e7f56d 100644 --- a/deepmd/entrypoints/ipi.py +++ b/deepmd/entrypoints/ipi.py @@ -2,9 +2,13 @@ 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/main.py b/deepmd/entrypoints/main.py index 33a7ad56b8..baa96bd7a1 100644 --- a/deepmd/entrypoints/main.py +++ b/deepmd/entrypoints/main.py @@ -3,23 +3,37 @@ import argparse import logging import textwrap -from pathlib import Path -from typing import List -from typing import Optional - -from deepmd import __version__ -from deepmd.common import clear_session -from deepmd.entrypoints import compress -from deepmd.entrypoints import convert -from deepmd.entrypoints import doc_train_input -from deepmd.entrypoints import freeze -from deepmd.entrypoints import make_model_devi -from deepmd.entrypoints import neighbor_stat -from deepmd.entrypoints import test -from deepmd.entrypoints import train_dp -from deepmd.entrypoints import transfer -from deepmd.loggers import set_log_handles -from deepmd.nvnmd.entrypoints.train import train_nvnmd +from pathlib import ( + Path, +) +from typing import ( + List, + Optional, +) + +from deepmd import ( + __version__, +) +from deepmd.common import ( + clear_session, +) +from deepmd.entrypoints import ( + compress, + convert, + doc_train_input, + freeze, + make_model_devi, + neighbor_stat, + test, + train_dp, + transfer, +) +from deepmd.loggers import ( + set_log_handles, +) +from deepmd.nvnmd.entrypoints.train import ( + train_nvnmd, +) __all__ = ["main", "parse_args", "get_ll", "main_parser"] diff --git a/deepmd/entrypoints/neighbor_stat.py b/deepmd/entrypoints/neighbor_stat.py index bfc17fdea6..226f312621 100644 --- a/deepmd/entrypoints/neighbor_stat.py +++ b/deepmd/entrypoints/neighbor_stat.py @@ -1,9 +1,17 @@ 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/test.py b/deepmd/entrypoints/test.py index 761862c330..ecab32aefb 100644 --- a/deepmd/entrypoints/test.py +++ b/deepmd/entrypoints/test.py @@ -1,27 +1,43 @@ """Test trained DeePMD model.""" import logging -from pathlib import Path -from typing import TYPE_CHECKING -from typing import Dict -from typing import List -from typing import Optional -from typing import Tuple +from pathlib import ( + Path, +) +from typing import ( + TYPE_CHECKING, + Dict, + List, + Optional, + Tuple, +) import numpy as np -from deepmd import DeepPotential -from deepmd.common import expand_sys_str +from deepmd import ( + DeepPotential, +) +from deepmd.common import ( + expand_sys_str, +) from deepmd.utils import random as dp_random -from deepmd.utils.data import DeepmdData -from deepmd.utils.weight_avg import weighted_average +from deepmd.utils.data import ( + DeepmdData, +) +from deepmd.utils.weight_avg import ( + weighted_average, +) if TYPE_CHECKING: - from deepmd.infer import DeepDipole - from deepmd.infer import DeepDOS - from deepmd.infer import DeepPolar - from deepmd.infer import DeepPot - from deepmd.infer import DeepWFC - from deepmd.infer.deep_tensor import DeepTensor + from deepmd.infer import ( + DeepDipole, + DeepDOS, + DeepPolar, + DeepPot, + DeepWFC, + ) + from deepmd.infer.deep_tensor import ( + DeepTensor, + ) __all__ = ["test"] diff --git a/deepmd/entrypoints/transfer.py b/deepmd/entrypoints/transfer.py index a067353e2c..8eeeb10653 100644 --- a/deepmd/entrypoints/transfer.py +++ b/deepmd/entrypoints/transfer.py @@ -2,14 +2,18 @@ import logging import re -from typing import Dict -from typing import Optional -from typing import Sequence +from typing import ( + Dict, + Optional, + Sequence, +) import numpy as np -from deepmd.env import TRANSFER_PATTERN -from deepmd.env import tf +from deepmd.env import ( + TRANSFER_PATTERN, + tf, +) __all__ = ["transfer"] diff --git a/deepmd/fit/__init__.py b/deepmd/fit/__init__.py index d5529c80e6..875c67cd5d 100644 --- a/deepmd/fit/__init__.py +++ b/deepmd/fit/__init__.py @@ -1,9 +1,19 @@ -from .dipole import DipoleFittingSeA -from .dos import DOSFitting -from .ener import EnerFitting -from .fitting import Fitting -from .polar import GlobalPolarFittingSeA -from .polar import PolarFittingSeA +from .dipole import ( + DipoleFittingSeA, +) +from .dos import ( + DOSFitting, +) +from .ener import ( + EnerFitting, +) +from .fitting import ( + Fitting, +) +from .polar import ( + GlobalPolarFittingSeA, + PolarFittingSeA, +) __all__ = [ "DipoleFittingSeA", diff --git a/deepmd/fit/dipole.py b/deepmd/fit/dipole.py index 52d68af480..9f497584ae 100644 --- a/deepmd/fit/dipole.py +++ b/deepmd/fit/dipole.py @@ -1,16 +1,28 @@ -from typing import List -from typing import Optional +from typing import ( + List, + Optional, +) import numpy as np -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 +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, +) @Fitting.register("dipole") diff --git a/deepmd/fit/dos.py b/deepmd/fit/dos.py index fa43634c16..4bb1838af1 100644 --- a/deepmd/fit/dos.py +++ b/deepmd/fit/dos.py @@ -1,23 +1,41 @@ import logging -from typing import List -from typing import Optional +from typing import ( + List, + Optional, +) import numpy as np -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.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.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/ener_tf.py b/deepmd/fit/ener_tf.py index 1f77d2fdb6..aacdf5b67f 100644 --- a/deepmd/fit/ener_tf.py +++ b/deepmd/fit/ener_tf.py @@ -1,31 +1,57 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import logging -from typing import List -from typing import Optional +from typing import ( + List, + Optional, +) import numpy as np -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 global_cvt_2_tf_float -from deepmd.env import tf -from deepmd.fit.fitting import Fitting -from deepmd.infer import DeepPotential -from deepmd.loss.ener import EnerDipoleLoss -from deepmd.loss.ener import EnerSpinLoss -from deepmd.loss.ener import EnerStdLoss -from deepmd.loss.loss import Loss -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.common import ( + add_data_requirement, + cast_precision, + get_activation_func, + get_precision, +) +from deepmd.env import ( + GLOBAL_TF_FLOAT_PRECISION, + global_cvt_2_tf_float, + tf, +) +from deepmd.fit.fitting import ( + Fitting, +) +from deepmd.infer import ( + DeepPotential, +) +from deepmd.loss.ener import ( + EnerDipoleLoss, + EnerSpinLoss, + EnerStdLoss, +) +from deepmd.loss.loss import ( + Loss, +) +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.utils.network import one_layer as one_layer_deepmd -from deepmd.utils.network import one_layer_rand_seed_shift -from deepmd.utils.spin import Spin +from deepmd.utils.network import ( + one_layer_rand_seed_shift, +) +from deepmd.utils.spin import ( + Spin, +) log = logging.getLogger(__name__) diff --git a/deepmd/fit/fitting.py b/deepmd/fit/fitting.py index a2fd225c9c..b0a9efe3be 100644 --- a/deepmd/fit/fitting.py +++ b/deepmd/fit/fitting.py @@ -1,8 +1,14 @@ -from typing import Callable +from typing import ( + Callable, +) -from deepmd.env import tf -from deepmd.utils import Plugin -from deepmd.utils import PluginVariant +from deepmd.env import ( + tf, +) +from deepmd.utils import ( + Plugin, + PluginVariant, +) class Fitting(PluginVariant): diff --git a/deepmd/fit/polar.py b/deepmd/fit/polar.py index 8a36aa4ea5..42b8d155f5 100644 --- a/deepmd/fit/polar.py +++ b/deepmd/fit/polar.py @@ -1,18 +1,32 @@ import warnings -from typing import List -from typing import Optional +from typing import ( + List, + Optional, +) import numpy as np -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 +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, +) @Fitting.register("polar") diff --git a/deepmd/infer/__init__.py b/deepmd/infer/__init__.py index e974411ed9..f87541c889 100644 --- a/deepmd/infer/__init__.py +++ b/deepmd/infer/__init__.py @@ -1,18 +1,40 @@ """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 -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 +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, +) __all__ = [ "DeepPotential", diff --git a/deepmd/infer/data_modifier.py b/deepmd/infer/data_modifier.py index a552cc5b16..2da80c572b 100644 --- a/deepmd/infer/data_modifier.py +++ b/deepmd/infer/data_modifier.py @@ -1,18 +1,32 @@ import os -from typing import List -from typing import Tuple +from typing import ( + List, + Tuple, +) import numpy as np -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 +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, +) class DipoleChargeModifier(DeepDipole): diff --git a/deepmd/infer/deep_dipole.py b/deepmd/infer/deep_dipole.py index 4b2384a152..e7eb1061de 100644 --- a/deepmd/infer/deep_dipole.py +++ b/deepmd/infer/deep_dipole.py @@ -1,9 +1,15 @@ -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 eb18c3fe69..2f6dc83d00 100644 --- a/deepmd/infer/deep_dos.py +++ b/deepmd/infer/deep_dos.py @@ -1,20 +1,32 @@ import logging -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 +from typing import ( + TYPE_CHECKING, + Callable, + List, + Optional, + Tuple, + 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 6cb58cff7c..f08ea9f64b 100644 --- a/deepmd/infer/deep_polar.py +++ b/deepmd/infer/deep_polar.py @@ -1,13 +1,19 @@ -from typing import TYPE_CHECKING -from typing import List -from typing import Optional +from typing import ( + TYPE_CHECKING, + List, + 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 8b31d91b2d..ca62b97385 100644 --- a/deepmd/infer/deep_tensor.py +++ b/deepmd/infer/deep_tensor.py @@ -1,16 +1,26 @@ -from typing import TYPE_CHECKING -from typing import List -from typing import Optional -from typing import Tuple +from typing import ( + TYPE_CHECKING, + List, + Optional, + 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 090ead5a33..36a77de35e 100644 --- a/deepmd/infer/deep_wfc.py +++ b/deepmd/infer/deep_wfc.py @@ -1,9 +1,15 @@ -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 405756d7a7..6db1d63520 100644 --- a/deepmd/infer/ewald_recp.py +++ b/deepmd/infer/ewald_recp.py @@ -1,12 +1,18 @@ -from typing import Tuple +from typing import ( + Tuple, +) import numpy as np -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 deepmd.env import ( + GLOBAL_TF_FLOAT_PRECISION, + default_tf_session_config, + op_module, + 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 8736573d73..114fb14f30 100644 --- a/deepmd/infer/model_devi.py +++ b/deepmd/infer/model_devi.py @@ -1,12 +1,22 @@ -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 0f6be85f04..72321832af 100644 --- a/deepmd/lmp.py +++ b/deepmd/lmp.py @@ -1,18 +1,30 @@ """Register entry points for lammps-wheel.""" import os import platform -from importlib import import_module -from pathlib import Path -from typing import List -from typing import Optional +from importlib import ( + import_module, +) +from pathlib import ( + Path, +) +from typing import ( + List, + Optional, +) -from packaging.version import Version +from packaging.version import ( + Version, +) -from deepmd.env import TF_VERSION -from deepmd.env import tf +from deepmd.env import ( + TF_VERSION, + 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 8eb1868ae3..f9cf3087e6 100644 --- a/deepmd/loggers/__init__.py +++ b/deepmd/loggers/__init__.py @@ -1,5 +1,7 @@ """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 3fff9fd2fd..9fe9530482 100644 --- a/deepmd/loggers/loggers.py +++ b/deepmd/loggers/loggers.py @@ -2,13 +2,19 @@ import logging import os -from typing import TYPE_CHECKING -from typing import Optional +from typing import ( + TYPE_CHECKING, + 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 @@ -200,7 +206,9 @@ 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 d4d82a1c69..bfd6e57397 100644 --- a/deepmd/loss/__init__.py +++ b/deepmd/loss/__init__.py @@ -1,8 +1,14 @@ -from .dos import DOSLoss -from .ener import EnerDipoleLoss -from .ener import EnerSpinLoss -from .ener import EnerStdLoss -from .tensor import TensorLoss +from .dos import ( + DOSLoss, +) +from .ener import ( + EnerDipoleLoss, + EnerSpinLoss, + EnerStdLoss, +) +from .tensor import ( + TensorLoss, +) __all__ = [ "EnerDipoleLoss", diff --git a/deepmd/loss/dos.py b/deepmd/loss/dos.py index 3373345a95..5a7e67e29c 100644 --- a/deepmd/loss/dos.py +++ b/deepmd/loss/dos.py @@ -1,12 +1,20 @@ import numpy as np -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 +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, +) class DOSLoss(Loss): diff --git a/deepmd/loss/loss.py b/deepmd/loss/loss.py index 7a9d55e106..423d9e118d 100644 --- a/deepmd/loss/loss.py +++ b/deepmd/loss/loss.py @@ -1,9 +1,15 @@ -from abc import ABCMeta -from abc import abstractmethod -from typing import Dict -from typing import Tuple +from abc import ( + ABCMeta, + abstractmethod, +) +from typing import ( + Dict, + Tuple, +) -from deepmd.env import tf +from deepmd.env import ( + tf, +) class Loss(metaclass=ABCMeta): diff --git a/deepmd/loss/tensor.py b/deepmd/loss/tensor.py index ff28b78ed5..e261be2bb1 100644 --- a/deepmd/loss/tensor.py +++ b/deepmd/loss/tensor.py @@ -1,11 +1,19 @@ import numpy as np -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 +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, +) class TensorLoss(Loss): diff --git a/deepmd/model/__init__.py b/deepmd/model/__init__.py index 423b6d2bcb..43f4b4a3a9 100644 --- a/deepmd/model/__init__.py +++ b/deepmd/model/__init__.py @@ -1,10 +1,18 @@ -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 +from .dos import ( + DOSModel, +) +from .ener import ( + EnerModel, +) +from .multi import ( + MultiModel, +) +from .tensor import ( + DipoleModel, + GlobalPolarModel, + PolarModel, + WFCModel, +) __all__ = [ "EnerModel", diff --git a/deepmd/model/dos.py b/deepmd/model/dos.py index 911104433e..0da709409f 100644 --- a/deepmd/model/dos.py +++ b/deepmd/model/dos.py @@ -1,13 +1,21 @@ -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 +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, +) class DOSModel(Model): diff --git a/deepmd/model/model_stat.py b/deepmd/model/model_stat.py index 764f592414..28f0eb4f1d 100644 --- a/deepmd/model/model_stat.py +++ b/deepmd/model/model_stat.py @@ -1,4 +1,6 @@ -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 7e616d050e..dcf7566f36 100644 --- a/deepmd/model/multi.py +++ b/deepmd/model/multi.py @@ -1,19 +1,31 @@ import json -from typing import List -from typing import Optional +from typing import ( + List, + Optional, +) import numpy as np -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 +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, +) class MultiModel(Model): diff --git a/deepmd/model/tensor.py b/deepmd/model/tensor.py index bff3af526f..eb32fa88cf 100644 --- a/deepmd/model/tensor.py +++ b/deepmd/model/tensor.py @@ -1,12 +1,20 @@ -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 +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, +) class TensorModel(Model): diff --git a/deepmd/nvnmd/__init__.py b/deepmd/nvnmd/__init__.py index bb3be2895b..f598ff416a 100644 --- a/deepmd/nvnmd/__init__.py +++ b/deepmd/nvnmd/__init__.py @@ -1,8 +1,10 @@ -from . import data -from . import descriptor -from . import entrypoints -from . import fit -from . import utils +from . import ( + data, + descriptor, + entrypoints, + fit, + utils, +) __all__ = [ "data", diff --git a/deepmd/nvnmd/descriptor/se_a.py b/deepmd/nvnmd/descriptor/se_a.py index ba8fb312aa..a18d8b85c9 100644 --- a/deepmd/nvnmd/descriptor/se_a.py +++ b/deepmd/nvnmd/descriptor/se_a.py @@ -2,16 +2,26 @@ import numpy as np -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.env import ( + GLOBAL_NP_FLOAT_PRECISION, + GLOBAL_TF_FLOAT_PRECISION, + op_module, + 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 5c61662405..6f737c710b 100644 --- a/deepmd/nvnmd/entrypoints/__init__.py +++ b/deepmd/nvnmd/entrypoints/__init__.py @@ -1,5 +1,11 @@ -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 d15cad6e44..019b2f3382 100644 --- a/deepmd/nvnmd/entrypoints/freeze.py +++ b/deepmd/nvnmd/entrypoints/freeze.py @@ -1,8 +1,14 @@ #!/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 8ca097d40d..50664a9552 100644 --- a/deepmd/nvnmd/entrypoints/mapt.py +++ b/deepmd/nvnmd/entrypoints/mapt.py @@ -1,18 +1,34 @@ import logging -from typing import Optional +from typing import ( + Optional, +) import numpy as np -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 +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, +) log = logging.getLogger(__name__) diff --git a/deepmd/nvnmd/entrypoints/train.py b/deepmd/nvnmd/entrypoints/train.py index 2d9863dbfd..b311ea7819 100644 --- a/deepmd/nvnmd/entrypoints/train.py +++ b/deepmd/nvnmd/entrypoints/train.py @@ -1,15 +1,33 @@ 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 e326de509c..4bf12803f2 100644 --- a/deepmd/nvnmd/entrypoints/wrap.py +++ b/deepmd/nvnmd/entrypoints/wrap.py @@ -1,19 +1,37 @@ import logging -from typing import Optional +from typing import ( + Optional, +) import numpy as np -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 +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, +) log = logging.getLogger(__name__) diff --git a/deepmd/nvnmd/fit/ener.py b/deepmd/nvnmd/fit/ener.py index 8a2cc69c8e..9a250af82d 100644 --- a/deepmd/nvnmd/fit/ener.py +++ b/deepmd/nvnmd/fit/ener.py @@ -1,6 +1,10 @@ -from deepmd.env import GLOBAL_TF_FLOAT_PRECISION -from deepmd.env import tf -from deepmd.nvnmd.utils.config import nvnmd_cfg +from deepmd.env import ( + GLOBAL_TF_FLOAT_PRECISION, + 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 8e35d0e88a..4e201d917e 100644 --- a/deepmd/nvnmd/utils/__init__.py +++ b/deepmd/nvnmd/utils/__init__.py @@ -1,13 +1,27 @@ -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 +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, +) __all__ = [ "nvnmd_args", diff --git a/deepmd/nvnmd/utils/argcheck.py b/deepmd/nvnmd/utils/argcheck.py index e91e135706..a53dae0d5a 100644 --- a/deepmd/nvnmd/utils/argcheck.py +++ b/deepmd/nvnmd/utils/argcheck.py @@ -1,4 +1,6 @@ -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 32b885d7ec..9d756f8ef1 100644 --- a/deepmd/nvnmd/utils/config.py +++ b/deepmd/nvnmd/utils/config.py @@ -2,13 +2,19 @@ import numpy as np -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 +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, +) log = logging.getLogger(__name__) diff --git a/deepmd/nvnmd/utils/encode.py b/deepmd/nvnmd/utils/encode.py index 905fa638c5..75cd629847 100644 --- a/deepmd/nvnmd/utils/encode.py +++ b/deepmd/nvnmd/utils/encode.py @@ -2,7 +2,9 @@ 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 04420a84c0..8493bfd15d 100644 --- a/deepmd/nvnmd/utils/fio.py +++ b/deepmd/nvnmd/utils/fio.py @@ -2,7 +2,9 @@ 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 9dba82ea7b..cf727b3eec 100644 --- a/deepmd/nvnmd/utils/network.py +++ b/deepmd/nvnmd/utils/network.py @@ -2,12 +2,20 @@ import numpy as np -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 +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, +) log = logging.getLogger(__name__) diff --git a/deepmd/nvnmd/utils/weight.py b/deepmd/nvnmd/utils/weight.py index b9a880a434..77208d0d0a 100644 --- a/deepmd/nvnmd/utils/weight.py +++ b/deepmd/nvnmd/utils/weight.py @@ -1,6 +1,8 @@ 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 eac431c247..cf7b8a90ea 100644 --- a/deepmd/op/__init__.py +++ b/deepmd/op/__init__.py @@ -2,7 +2,9 @@ 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 6c859919b1..e62ee7ef63 100644 --- a/deepmd/train/run_options.py +++ b/deepmd/train/run_options.py @@ -2,17 +2,27 @@ import logging import os -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 +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, +) if TYPE_CHECKING: import horovod.tensorflow as HVD diff --git a/deepmd/utils/__init__.py b/deepmd/utils/__init__.py index 75b8b25b51..e7b79e1f28 100644 --- a/deepmd/utils/__init__.py +++ b/deepmd/utils/__init__.py @@ -1,10 +1,20 @@ # -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 +from .data import ( + DeepmdData, +) +from .data_system import ( + DeepmdDataSystem, +) +from .learning_rate import ( + LearningRateExp, +) +from .pair_tab import ( + PairTab, +) +from .plugin import ( + Plugin, + PluginVariant, +) __all__ = [ "DeepmdData", diff --git a/deepmd/utils/argcheck.py b/deepmd/utils/argcheck.py index 370a67361f..1fe00b4f43 100644 --- a/deepmd/utils/argcheck.py +++ b/deepmd/utils/argcheck.py @@ -1,18 +1,28 @@ import json import logging -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 +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, +) log = logging.getLogger(__name__) diff --git a/deepmd/utils/batch_size.py b/deepmd/utils/batch_size.py index 5b55261d06..a2cafef23e 100644 --- a/deepmd/utils/batch_size.py +++ b/deepmd/utils/batch_size.py @@ -1,12 +1,18 @@ import logging import os -from typing import Callable -from typing import Tuple +from typing import ( + Callable, + Tuple, +) import numpy as np -from deepmd.env import tf -from deepmd.utils.errors import OutOfMemoryError +from deepmd.env import ( + tf, +) +from deepmd.utils.errors import ( + OutOfMemoryError, +) log = logging.getLogger(__name__) diff --git a/deepmd/utils/compat.py b/deepmd/utils/compat.py index 287a835b91..4ec47b53a1 100644 --- a/deepmd/utils/compat.py +++ b/deepmd/utils/compat.py @@ -2,16 +2,22 @@ import json import warnings -from pathlib import Path -from typing import Any -from typing import Dict -from typing import Optional -from typing import Sequence -from typing import Union +from pathlib import ( + Path, +) +from typing import ( + Any, + Dict, + Optional, + Sequence, + 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 2fe55e2581..4948a8e70f 100644 --- a/deepmd/utils/convert.py +++ b/deepmd/utils/convert.py @@ -1,9 +1,13 @@ 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.py b/deepmd/utils/data.py index 8ffb7bc58a..2749a45594 100644 --- a/deepmd/utils/data.py +++ b/deepmd/utils/data.py @@ -1,15 +1,21 @@ #!/usr/bin/env python3 import logging -from typing import List -from typing import Optional +from typing import ( + List, + Optional, +) import numpy as np -from deepmd.env import GLOBAL_ENER_FLOAT_PRECISION -from deepmd.env import GLOBAL_NP_FLOAT_PRECISION +from deepmd.env import ( + GLOBAL_ENER_FLOAT_PRECISION, + GLOBAL_NP_FLOAT_PRECISION, +) from deepmd.utils import random as dp_random -from deepmd.utils.path import DPPath +from deepmd.utils.path import ( + DPPath, +) log = logging.getLogger(__name__) diff --git a/deepmd/utils/data_system.py b/deepmd/utils/data_system.py index dc1fb25464..f7bc1c500d 100644 --- a/deepmd/utils/data_system.py +++ b/deepmd/utils/data_system.py @@ -1,14 +1,20 @@ import collections import logging import warnings -from typing import List -from typing import Optional +from typing import ( + List, + 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 0107a09d17..9b39d68b30 100644 --- a/deepmd/utils/finetune.py +++ b/deepmd/utils/finetune.py @@ -1,10 +1,16 @@ import json import logging -from typing import Any -from typing import Dict +from typing import ( + Any, + 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 9c46c28dc0..71858039b1 100644 --- a/deepmd/utils/graph.py +++ b/deepmd/utils/graph.py @@ -1,16 +1,24 @@ import re -from typing import Dict -from typing import Tuple +from typing import ( + Dict, + Tuple, +) import numpy as np -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 +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, +) # 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 08f1865c91..d5496b47ea 100644 --- a/deepmd/utils/multi_init.py +++ b/deepmd/utils/multi_init.py @@ -1,10 +1,16 @@ import json import logging -from typing import Any -from typing import Dict +from typing import ( + Any, + 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/network.py b/deepmd/utils/network.py index e3c2420c35..5824caed34 100644 --- a/deepmd/utils/network.py +++ b/deepmd/utils/network.py @@ -305,13 +305,13 @@ def variable_summaries(var: tf.Variable, name: str): tf.summary.scalar("min", tf.reduce_min(var)) tf.summary.histogram("histogram", var) - + def cast_to_dtype(x, dtype: paddle.dtype) -> paddle.Tensor: if x.dtype != dtype: return paddle.cast(x, dtype) return x - + class OneLayer(nn.Layer): def __init__( self, diff --git a/deepmd/utils/pair_tab.py b/deepmd/utils/pair_tab.py index 13dcef438a..b8642c7009 100644 --- a/deepmd/utils/pair_tab.py +++ b/deepmd/utils/pair_tab.py @@ -1,9 +1,13 @@ #!/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 1453e9377f..db27d5604e 100644 --- a/deepmd/utils/parallel_op.py +++ b/deepmd/utils/parallel_op.py @@ -1,12 +1,18 @@ -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 typing import ( + Any, + Callable, + Dict, + Generator, + Optional, + 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 ba1f1e87a2..454eed3d2b 100644 --- a/deepmd/utils/path.py +++ b/deepmd/utils/path.py @@ -1,14 +1,24 @@ import os -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 +from abc import ( + ABC, + abstractmethod, +) +from functools import ( + lru_cache, +) +from pathlib import ( + Path, +) +from typing import ( + List, + 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 c49328ef2b..66b4569029 100644 --- a/deepmd/utils/plugin.py +++ b/deepmd/utils/plugin.py @@ -1,8 +1,12 @@ """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 0632d6bc64..57d0af4d55 100644 --- a/deepmd/utils/random.py +++ b/deepmd/utils/random.py @@ -1,4 +1,6 @@ -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 53e0abd850..67bbd36878 100644 --- a/deepmd/utils/sess.py +++ b/deepmd/utils/sess.py @@ -1,7 +1,11 @@ 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/tabulate.py b/deepmd/utils/tabulate.py index a8ce9fd9d4..aa842178f7 100644 --- a/deepmd/utils/tabulate.py +++ b/deepmd/utils/tabulate.py @@ -1,20 +1,34 @@ import logging -from functools import lru_cache -from typing import Callable -from typing import Dict -from typing import List -from typing import Tuple +from functools import ( + lru_cache, +) +from typing import ( + Callable, + Dict, + List, + 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 -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 +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, +) log = logging.getLogger(__name__) diff --git a/deepmd/utils/weight_avg.py b/deepmd/utils/weight_avg.py index 728094e563..b46e3a0d37 100644 --- a/deepmd/utils/weight_avg.py +++ b/deepmd/utils/weight_avg.py @@ -1,7 +1,11 @@ -from collections import defaultdict -from typing import Dict -from typing import List -from typing import Tuple +from collections import ( + defaultdict, +) +from typing import ( + Dict, + List, + Tuple, +) import numpy as np diff --git a/doc/conf.py b/doc/conf.py index 519ce94f1c..5e034b36c1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -12,11 +12,17 @@ # import os import sys -from datetime import date +from datetime import ( + date, +) -from deepmd.common import ACTIVATION_FN_DICT -from deepmd.common import PRECISION_DICT -from deepmd.utils.argcheck import list_to_doc +from deepmd.common import ( + ACTIVATION_FN_DICT, + PRECISION_DICT, +) +from deepmd.utils.argcheck import ( + list_to_doc, +) sys.path.append(os.path.dirname(__file__)) import sphinx_contrib_exhale_multiproject # noqa: F401 @@ -121,7 +127,9 @@ 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/sphinx_contrib_exhale_multiproject.py b/doc/sphinx_contrib_exhale_multiproject.py index cf0cc9850f..208637aa5e 100644 --- a/doc/sphinx_contrib_exhale_multiproject.py +++ b/doc/sphinx_contrib_exhale_multiproject.py @@ -74,7 +74,9 @@ import os import os.path -from pprint import pprint +from pprint import ( + pprint, +) import exhale import exhale.configs diff --git a/setup.py b/setup.py index 026a8b5fe4..b08fe391df 100644 --- a/setup.py +++ b/setup.py @@ -3,16 +3,24 @@ import os import sys -from packaging.version import Version -from skbuild import setup -from wheel.bdist_wheel import bdist_wheel +from packaging.version import ( + Version, +) +from skbuild import ( + setup, +) +from wheel.bdist_wheel import ( + bdist_wheel, +) topdir = os.path.abspath(os.path.dirname(__file__)) sys.path.insert(0, os.path.join(topdir, "backend")) -from find_tensorflow import find_tensorflow -from find_tensorflow import get_tf_requirement -from find_tensorflow import get_tf_version +from find_tensorflow import ( + find_tensorflow, + get_tf_requirement, + get_tf_version, +) cmake_args = [] extra_scripts = [] diff --git a/source/install/build_tf.py b/source/install/build_tf.py index 4a304676f1..883c654b5c 100755 --- a/source/install/build_tf.py +++ b/source/install/build_tf.py @@ -32,19 +32,33 @@ import tarfile import tempfile import urllib.request -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 +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, +) # default config FILE = Path(__file__).parent.absolute() diff --git a/source/lib/paddle_src/paddle_prod_env_mat.cu b/source/lib/paddle_src/paddle_prod_env_mat.cu index d0f58ff896..c18fb7d687 100644 --- a/source/lib/paddle_src/paddle_prod_env_mat.cu +++ b/source/lib/paddle_src/paddle_prod_env_mat.cu @@ -18,10 +18,8 @@ #include "region.h" #include "utilities.h" - typedef long long int_64; - #define CHECK_INPUT(x) PD_CHECK(x.is_gpu(), #x " must be a GPU Tensor.") #define CHECK_INPUT_ON_CPU(x) PD_CHECK(x.is_cpu(), #x " must be a CPU Tensor.") #define CHECK_INPUT_DIM(x, value) \ diff --git a/source/lmp/tests/test_deeptensor.py b/source/lmp/tests/test_deeptensor.py index 32fad73404..0029247959 100644 --- a/source/lmp/tests/test_deeptensor.py +++ b/source/lmp/tests/test_deeptensor.py @@ -1,12 +1,18 @@ 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 0d0efad2c8..b6398b77be 100644 --- a/source/lmp/tests/test_dplr.py +++ b/source/lmp/tests/test_dplr.py @@ -1,12 +1,18 @@ 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 e5e7eff307..f5cb7bac14 100644 --- a/source/lmp/tests/test_lammps.py +++ b/source/lmp/tests/test_lammps.py @@ -1,12 +1,18 @@ 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 07843cdfd2..24ef0fae38 100644 --- a/source/lmp/tests/test_lammps_3types.py +++ b/source/lmp/tests/test_lammps_3types.py @@ -1,12 +1,18 @@ 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 b001602507..0eedd0372c 100644 --- a/source/op/_add_flt_nvnmd_grad.py +++ b/source/op/_add_flt_nvnmd_grad.py @@ -1,8 +1,12 @@ #!/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 2dbcfcbc49..47b8956143 100644 --- a/source/op/_copy_flt_nvnmd_grad.py +++ b/source/op/_copy_flt_nvnmd_grad.py @@ -1,8 +1,12 @@ #!/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 42bc2614f3..97653b1540 100644 --- a/source/op/_dotmul_flt_nvnmd_grad.py +++ b/source/op/_dotmul_flt_nvnmd_grad.py @@ -1,9 +1,13 @@ #!/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 tf +from deepmd.env import ( + op_module, + tf, +) @ops.RegisterGradient("DotmulFltNvnmd") diff --git a/source/op/_flt_nvnmd_grad.py b/source/op/_flt_nvnmd_grad.py index 58408ad616..471bc35b1c 100644 --- a/source/op/_flt_nvnmd_grad.py +++ b/source/op/_flt_nvnmd_grad.py @@ -1,8 +1,12 @@ #!/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 2255ee61be..19b2a3f240 100644 --- a/source/op/_gelu.py +++ b/source/op/_gelu.py @@ -1,9 +1,13 @@ #!/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 caeb3de171..434701bc6e 100644 --- a/source/op/_map_flt_nvnmd_grad.py +++ b/source/op/_map_flt_nvnmd_grad.py @@ -1,9 +1,13 @@ #!/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 tf +from deepmd.env import ( + op_module, + tf, +) @ops.RegisterGradient("MapFltNvnmd") diff --git a/source/op/_matmul_fitnet_nvnmd_grad.py b/source/op/_matmul_fitnet_nvnmd_grad.py index fa4c92d493..77fafb7d24 100644 --- a/source/op/_matmul_fitnet_nvnmd_grad.py +++ b/source/op/_matmul_fitnet_nvnmd_grad.py @@ -1,9 +1,13 @@ #!/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 tf +from deepmd.env import ( + op_module, + tf, +) @ops.RegisterGradient("MatmulFitnetNvnmd") diff --git a/source/op/_matmul_flt2fix_nvnmd.py b/source/op/_matmul_flt2fix_nvnmd.py index 670674103d..3b47b14a09 100644 --- a/source/op/_matmul_flt2fix_nvnmd.py +++ b/source/op/_matmul_flt2fix_nvnmd.py @@ -1,9 +1,13 @@ #!/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 tf +from deepmd.env import ( + op_module, + tf, +) @ops.RegisterGradient("MatmulFlt2fixNvnmd") diff --git a/source/op/_matmul_flt_nvnmd_grad.py b/source/op/_matmul_flt_nvnmd_grad.py index 1e9f980508..383e464e64 100644 --- a/source/op/_matmul_flt_nvnmd_grad.py +++ b/source/op/_matmul_flt_nvnmd_grad.py @@ -1,9 +1,13 @@ #!/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 tf +from deepmd.env import ( + op_module, + tf, +) @ops.RegisterGradient("MatmulFltNvnmd") diff --git a/source/op/_mul_flt_nvnmd_grad.py b/source/op/_mul_flt_nvnmd_grad.py index 634fa56484..e1fb72ac6b 100644 --- a/source/op/_mul_flt_nvnmd_grad.py +++ b/source/op/_mul_flt_nvnmd_grad.py @@ -1,9 +1,13 @@ #!/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 tf +from deepmd.env import ( + op_module, + tf, +) @ops.RegisterGradient("MulFltNvnmd") diff --git a/source/op/_prod_force_grad.py b/source/op/_prod_force_grad.py index 3fb5296057..8cdd37675c 100644 --- a/source/op/_prod_force_grad.py +++ b/source/op/_prod_force_grad.py @@ -1,9 +1,13 @@ #!/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 56e36d8a4a..cdfa73e4ad 100644 --- a/source/op/_prod_force_se_a_grad.py +++ b/source/op/_prod_force_se_a_grad.py @@ -1,9 +1,13 @@ #!/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 9fc7a994b7..b4c4f8fabc 100644 --- a/source/op/_prod_force_se_a_mask_grad.py +++ b/source/op/_prod_force_se_a_mask_grad.py @@ -1,9 +1,13 @@ #!/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 0a092961a6..447c388912 100644 --- a/source/op/_prod_force_se_r_grad.py +++ b/source/op/_prod_force_se_r_grad.py @@ -1,9 +1,13 @@ #!/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 e4c1bad3d0..aa8cca0939 100644 --- a/source/op/_prod_virial_grad.py +++ b/source/op/_prod_virial_grad.py @@ -1,9 +1,13 @@ #!/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 043bf7b737..6167795b7c 100644 --- a/source/op/_prod_virial_se_a_grad.py +++ b/source/op/_prod_virial_se_a_grad.py @@ -1,9 +1,13 @@ #!/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 c9c395eb7b..bb7680203d 100644 --- a/source/op/_prod_virial_se_r_grad.py +++ b/source/op/_prod_virial_se_r_grad.py @@ -1,9 +1,13 @@ #!/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 c7d2e1d076..64a492c04f 100644 --- a/source/op/_quantize_nvnmd_grad.py +++ b/source/op/_quantize_nvnmd_grad.py @@ -1,8 +1,12 @@ #!/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 0ea5db0c6d..c8519886d5 100644 --- a/source/op/_soft_min_force_grad.py +++ b/source/op/_soft_min_force_grad.py @@ -1,9 +1,13 @@ #!/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 a12050ee6a..f35bba9080 100644 --- a/source/op/_soft_min_virial_grad.py +++ b/source/op/_soft_min_virial_grad.py @@ -1,9 +1,13 @@ #!/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 369d584e9e..785146cfcc 100644 --- a/source/op/_tabulate_grad.py +++ b/source/op/_tabulate_grad.py @@ -1,9 +1,13 @@ #!/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 bcfc01dbe9..9ccfe701df 100644 --- a/source/op/_tanh4_flt_nvnmd_grad.py +++ b/source/op/_tanh4_flt_nvnmd_grad.py @@ -1,8 +1,12 @@ #!/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 a450fcca00..dcbccd221a 100644 --- a/source/tests/common.py +++ b/source/tests/common.py @@ -8,9 +8,13 @@ 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 -from deepmd.env import tf +from deepmd.entrypoints.main import ( + main, +) +from deepmd.env import ( + GLOBAL_NP_FLOAT_PRECISION, + 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 ade5afab21..4b0a430c35 100644 --- a/source/tests/test_activation_fn_gelu.py +++ b/source/tests/test_activation_fn_gelu.py @@ -2,9 +2,15 @@ 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 f9d876f8df..f7908af01c 100644 --- a/source/tests/test_adjust_sel.py +++ b/source/tests/test_adjust_sel.py @@ -6,12 +6,18 @@ import numpy as np # from deepmd.entrypoints.compress import compress -from common import j_loader -from common import run_dp -from common import tests_path +from common import ( + j_loader, + run_dp, + 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 2dd1cf0646..e48a2da24b 100644 --- a/source/tests/test_argument_parser.py +++ b/source/tests/test_argument_parser.py @@ -2,18 +2,28 @@ import re import unittest -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 +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, +) if TYPE_CHECKING: try: diff --git a/source/tests/test_auto_batch_size.py b/source/tests/test_auto_batch_size.py index 5fa7e2c4f7..bd863b2633 100644 --- a/source/tests/test_auto_batch_size.py +++ b/source/tests/test_auto_batch_size.py @@ -3,8 +3,12 @@ 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 53a2ace763..ceaddf41d4 100644 --- a/source/tests/test_cluster.py +++ b/source/tests/test_cluster.py @@ -1,8 +1,12 @@ import unittest -from unittest import mock - -from deepmd.cluster import local -from deepmd.cluster import slurm +from unittest import ( + mock, +) + +from deepmd.cluster import ( + local, + slurm, +) kHostName = "compute-b24-1" diff --git a/source/tests/test_common.py b/source/tests/test_common.py index 7bfe700a51..c3d6172f5b 100644 --- a/source/tests/test_common.py +++ b/source/tests/test_common.py @@ -1,11 +1,17 @@ import shutil import unittest -from pathlib import Path +from pathlib import ( + Path, +) -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 +from deepmd.common import ( + GLOBAL_TF_FLOAT_PRECISION, + cast_precision, + 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 91a51e52c6..df5fcd45f7 100644 --- a/source/tests/test_compat_input.py +++ b/source/tests/test_compat_input.py @@ -1,10 +1,14 @@ import os import unittest -from common import j_loader - -from deepmd.utils.compat import convert_input_v0_v1 -from deepmd.utils.compat import convert_input_v1_v2 +from common import ( + j_loader, +) + +from deepmd.utils.compat import ( + convert_input_v0_v1, + 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 ba7f425c6d..531c6de4f3 100644 --- a/source/tests/test_data_large_batch.py +++ b/source/tests/test_data_large_batch.py @@ -1,17 +1,33 @@ import unittest import numpy as np -from common import gen_data -from common import j_loader +from common import ( + gen_data, + 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 793dc0540f..99395f1127 100644 --- a/source/tests/test_data_modifier.py +++ b/source/tests/test_data_modifier.py @@ -1,18 +1,32 @@ import os import numpy as np -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 +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, +) 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 62725407de..7a7a9628e1 100644 --- a/source/tests/test_data_modifier_shuffle.py +++ b/source/tests/test_data_modifier_shuffle.py @@ -3,15 +3,29 @@ import numpy as np -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 +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, +) 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 cc204cc818..c407e3d5bd 100644 --- a/source/tests/test_data_requirement.py +++ b/source/tests/test_data_requirement.py @@ -1,7 +1,9 @@ import unittest -from deepmd.common import add_data_requirement -from deepmd.common import data_requirement +from deepmd.common import ( + add_data_requirement, + data_requirement, +) class TestDataRequirement(unittest.TestCase): diff --git a/source/tests/test_deepdipole.py b/source/tests/test_deepdipole.py index 7b41f1d244..ee96a74392 100644 --- a/source/tests/test_deepdipole.py +++ b/source/tests/test_deepdipole.py @@ -2,15 +2,23 @@ import unittest import numpy as np -from common import finite_difference -from common import strerch_box -from common import tests_path -from common import tf +from common import ( + finite_difference, + strerch_box, + tests_path, + 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 2d405ee201..c8968c04d5 100644 --- a/source/tests/test_deepdos.py +++ b/source/tests/test_deepdos.py @@ -2,11 +2,19 @@ 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 1166ab9950..3861b37312 100644 --- a/source/tests/test_deepmd_data.py +++ b/source/tests/test_deepmd_data.py @@ -4,10 +4,16 @@ 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 4b1d6d9509..5ed9d3d3f6 100644 --- a/source/tests/test_deepmd_data_sys.py +++ b/source/tests/test_deepmd_data_sys.py @@ -4,9 +4,15 @@ 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 28530580e8..10c2fefb33 100644 --- a/source/tests/test_deeppolar.py +++ b/source/tests/test_deeppolar.py @@ -2,13 +2,21 @@ import unittest import numpy as np -from common import tests_path -from common import tf +from common import ( + tests_path, + 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 57cf70beaf..a0a3bd0f33 100644 --- a/source/tests/test_deeppot_a.py +++ b/source/tests/test_deeppot_a.py @@ -3,19 +3,27 @@ import unittest import numpy as np -from common import run_dp -from common import tests_path +from common import ( + run_dp, + tests_path, +) -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 +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, +) if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 @@ -664,9 +672,13 @@ 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 acc11b8305..36d840b831 100644 --- a/source/tests/test_deeppot_r.py +++ b/source/tests/test_deeppot_r.py @@ -2,11 +2,19 @@ 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 0d4db8fd57..516633b9e6 100644 --- a/source/tests/test_deeppot_spin.py +++ b/source/tests/test_deeppot_spin.py @@ -2,11 +2,19 @@ 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 3e24465f84..a0e560c331 100644 --- a/source/tests/test_descrpt_nonsmth.py +++ b/source/tests/test_descrpt_nonsmth.py @@ -1,17 +1,21 @@ import unittest import numpy as np -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 common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) # load grad of force module -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.env import ( + GLOBAL_NP_FLOAT_PRECISION, + GLOBAL_TF_FLOAT_PRECISION, + op_module, + tf, +) class Inter: diff --git a/source/tests/test_descrpt_se_a_mask.py b/source/tests/test_descrpt_se_a_mask.py index d5011f9c58..b5281b0ed4 100644 --- a/source/tests/test_descrpt_se_a_mask.py +++ b/source/tests/test_descrpt_se_a_mask.py @@ -2,14 +2,26 @@ import pathlib import numpy as np -from common import DataSystem -from common import j_loader +from common import ( + DataSystem, + 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 604a909b85..e143709b47 100644 --- a/source/tests/test_descrpt_se_a_type.py +++ b/source/tests/test_descrpt_se_a_type.py @@ -1,12 +1,22 @@ import numpy as np -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 +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, +) 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 459190ac16..cfa2cdaae5 100644 --- a/source/tests/test_descrpt_se_atten.py +++ b/source/tests/test_descrpt_se_atten.py @@ -1,15 +1,25 @@ import unittest import numpy as np -from common import DataSystem -from common import gen_data -from common import j_loader +from common import ( + DataSystem, + gen_data, + 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 6778136b91..362d64f58d 100644 --- a/source/tests/test_descrpt_se_r.py +++ b/source/tests/test_descrpt_se_r.py @@ -1,17 +1,21 @@ import unittest import numpy as np -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 common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) # load grad of force module -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.env import ( + GLOBAL_NP_FLOAT_PRECISION, + GLOBAL_TF_FLOAT_PRECISION, + op_module, + tf, +) class Inter: diff --git a/source/tests/test_descrpt_sea_ef.py b/source/tests/test_descrpt_sea_ef.py index 545920cd3e..ef0712c5ae 100644 --- a/source/tests/test_descrpt_sea_ef.py +++ b/source/tests/test_descrpt_sea_ef.py @@ -1,17 +1,21 @@ import unittest import numpy as np -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 common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) # load grad of force module -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.env import ( + GLOBAL_NP_FLOAT_PRECISION, + GLOBAL_TF_FLOAT_PRECISION, + op_module, + tf, +) class Inter: diff --git a/source/tests/test_descrpt_sea_ef_para.py b/source/tests/test_descrpt_sea_ef_para.py index f7dff2151f..68696ac4f0 100644 --- a/source/tests/test_descrpt_sea_ef_para.py +++ b/source/tests/test_descrpt_sea_ef_para.py @@ -1,17 +1,21 @@ import unittest import numpy as np -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 common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) # load grad of force module -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.env import ( + GLOBAL_NP_FLOAT_PRECISION, + GLOBAL_TF_FLOAT_PRECISION, + op_module, + tf, +) class Inter: diff --git a/source/tests/test_descrpt_sea_ef_rot.py b/source/tests/test_descrpt_sea_ef_rot.py index 9098422662..cdeb51350e 100644 --- a/source/tests/test_descrpt_sea_ef_rot.py +++ b/source/tests/test_descrpt_sea_ef_rot.py @@ -2,12 +2,16 @@ import numpy as np -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 +from deepmd.descriptor import ( + DescrptSeA, + DescrptSeAEfLower, +) +from deepmd.env import ( + GLOBAL_NP_FLOAT_PRECISION, + GLOBAL_TF_FLOAT_PRECISION, + op_module, + 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 e8b48583b5..67269cff77 100644 --- a/source/tests/test_descrpt_sea_ef_vert.py +++ b/source/tests/test_descrpt_sea_ef_vert.py @@ -1,17 +1,21 @@ import unittest import numpy as np -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 common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) # load grad of force module -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.env import ( + GLOBAL_NP_FLOAT_PRECISION, + GLOBAL_TF_FLOAT_PRECISION, + op_module, + tf, +) class Inter: diff --git a/source/tests/test_descrpt_smooth.py b/source/tests/test_descrpt_smooth.py index 3092ffd8c8..a42bfa91dc 100644 --- a/source/tests/test_descrpt_smooth.py +++ b/source/tests/test_descrpt_smooth.py @@ -1,17 +1,21 @@ import unittest import numpy as np -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 common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) # load grad of force module -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.env import ( + GLOBAL_NP_FLOAT_PRECISION, + GLOBAL_TF_FLOAT_PRECISION, + op_module, + tf, +) class Inter: diff --git a/source/tests/test_dipole_se_a.py b/source/tests/test_dipole_se_a.py index ca6bb968e3..6203338cf7 100644 --- a/source/tests/test_dipole_se_a.py +++ b/source/tests/test_dipole_se_a.py @@ -1,15 +1,27 @@ import numpy as np -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 +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, +) 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 2a8fb93e83..5eda943255 100644 --- a/source/tests/test_dipole_se_a_tebd.py +++ b/source/tests/test_dipole_se_a_tebd.py @@ -1,19 +1,33 @@ import unittest import numpy as np -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 common import ( + DataSystem, + finite_difference, + gen_data, + j_loader, + 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 b3119f08eb..8fce3c2e12 100644 --- a/source/tests/test_dipolecharge.py +++ b/source/tests/test_dipolecharge.py @@ -2,11 +2,19 @@ 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 a50a071af3..7fb238e9e2 100644 --- a/source/tests/test_embedding_net.py +++ b/source/tests/test_embedding_net.py @@ -2,8 +2,12 @@ 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 25480f8056..e1864306c3 100644 --- a/source/tests/test_env.py +++ b/source/tests/test_env.py @@ -1,7 +1,11 @@ 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 b5b805ce74..0f6fb85228 100644 --- a/source/tests/test_ewald.py +++ b/source/tests/test_ewald.py @@ -1,10 +1,14 @@ import numpy as np -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 +from deepmd.env import ( + GLOBAL_NP_FLOAT_PRECISION, + GLOBAL_TF_FLOAT_PRECISION, + tf, +) +from deepmd.infer.ewald_recp import ( + EwaldRecp, + 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 13c0bc2758..138a7205b5 100644 --- a/source/tests/test_examples.py +++ b/source/tests/test_examples.py @@ -2,10 +2,16 @@ 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 d0e0601636..18c89f0153 100644 --- a/source/tests/test_finetune_se_atten.py +++ b/source/tests/test_finetune_se_atten.py @@ -4,18 +4,32 @@ import unittest import numpy as np -from common import j_loader -from common import run_dp -from common import tests_path +from common import ( + j_loader, + run_dp, + tests_path, +) from packaging.version import parse as parse_version -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 +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, +) 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 c91bf6d3d7..7e4c5f4c07 100644 --- a/source/tests/test_fitting_dos.py +++ b/source/tests/test_fitting_dos.py @@ -1,12 +1,22 @@ import numpy as np -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 +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, +) 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 fe4c452490..ca0c7afd79 100644 --- a/source/tests/test_fitting_ener_type.py +++ b/source/tests/test_fitting_ener_type.py @@ -1,12 +1,22 @@ import numpy as np -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 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, +) 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 536f130d7a..8ea1ff8b68 100644 --- a/source/tests/test_fitting_stat.py +++ b/source/tests/test_fitting_stat.py @@ -1,11 +1,19 @@ 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 48e7deeb6e..eac279a3a4 100644 --- a/source/tests/test_gen_stat_data.py +++ b/source/tests/test_gen_stat_data.py @@ -4,13 +4,21 @@ 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 -from deepmd.model.model_stat import make_stat_input -from deepmd.model.model_stat import merge_sys_stat +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.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 9d13c48074..869325e1c3 100644 --- a/source/tests/test_get_potential.py +++ b/source/tests/test_get_potential.py @@ -1,13 +1,19 @@ """Test if `DeepPotential` facto function returns the right type of potential.""" import unittest -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 +from pathlib import ( + Path, +) + +from deepmd.infer import ( + DeepDipole, + DeepPolar, + DeepPot, + 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 b4ea0d42c0..e7cf2a5f7f 100644 --- a/source/tests/test_init_frz_model_multi.py +++ b/source/tests/test_init_frz_model_multi.py @@ -3,18 +3,34 @@ import unittest import numpy as np -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 +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, +) 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 554a0f0054..2e73254e84 100644 --- a/source/tests/test_init_frz_model_se_a.py +++ b/source/tests/test_init_frz_model_se_a.py @@ -3,17 +3,31 @@ import unittest import numpy as np -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 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, +) 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 11acc5a237..dd09f0d3c2 100644 --- a/source/tests/test_init_frz_model_se_a_type.py +++ b/source/tests/test_init_frz_model_se_a_type.py @@ -3,17 +3,31 @@ import unittest import numpy as np -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 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, +) 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 3c5bb940b7..86a4fd86b9 100644 --- a/source/tests/test_init_frz_model_se_atten.py +++ b/source/tests/test_init_frz_model_se_atten.py @@ -3,18 +3,32 @@ import unittest import numpy as np -from common import j_loader -from common import run_dp -from common import tests_path +from common import ( + j_loader, + run_dp, + tests_path, +) from packaging.version import parse as parse_version -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.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, +) 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 0c312e9ded..04fb62d45d 100644 --- a/source/tests/test_init_frz_model_se_r.py +++ b/source/tests/test_init_frz_model_se_r.py @@ -3,17 +3,31 @@ import unittest import numpy as np -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 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, +) 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 f17a1c3079..18fcb71773 100644 --- a/source/tests/test_init_frz_model_spin.py +++ b/source/tests/test_init_frz_model_spin.py @@ -3,17 +3,31 @@ import unittest import numpy as np -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 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, +) 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 341b70fdfd..c1a8036a7f 100644 --- a/source/tests/test_lammps.py +++ b/source/tests/test_lammps.py @@ -1,9 +1,13 @@ 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 9f3d412ffa..db7bb18d2a 100644 --- a/source/tests/test_layer_name.py +++ b/source/tests/test_layer_name.py @@ -1,15 +1,27 @@ import numpy as np -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 +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, +) 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 f710f793f4..4becf9464b 100644 --- a/source/tests/test_mixed_prec_training.py +++ b/source/tests/test_mixed_prec_training.py @@ -6,12 +6,18 @@ import numpy as np # from deepmd.entrypoints.compress import compress -from common import j_loader -from common import run_dp -from common import tests_path -from packaging.version import Version +from common import ( + j_loader, + run_dp, + 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 9e66f419ff..dcd42184ca 100644 --- a/source/tests/test_model_compression_se_a.py +++ b/source/tests/test_model_compression_se_a.py @@ -6,12 +6,18 @@ import numpy as np # from deepmd.entrypoints.compress import compress -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 common import ( + j_loader, + run_dp, + 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 @@ -371,9 +377,13 @@ 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 6cf332f42d..c39c6470ed 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,12 +6,18 @@ import numpy as np # from deepmd.entrypoints.compress import compress -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 common import ( + j_loader, + run_dp, + 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 3751ff09d2..f85546b7ee 100644 --- a/source/tests/test_model_compression_se_r.py +++ b/source/tests/test_model_compression_se_r.py @@ -6,12 +6,18 @@ import numpy as np # from deepmd.entrypoints.compress import compress -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 common import ( + j_loader, + run_dp, + 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 @@ -379,9 +385,13 @@ 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 fc6b0e3f18..0e33430158 100644 --- a/source/tests/test_model_compression_se_t.py +++ b/source/tests/test_model_compression_se_t.py @@ -6,12 +6,18 @@ import numpy as np # from deepmd.entrypoints.compress import compress -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 common import ( + j_loader, + run_dp, + 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 @@ -401,9 +407,13 @@ 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 5091648d6c..20dd57386b 100644 --- a/source/tests/test_model_devi.py +++ b/source/tests/test_model_devi.py @@ -4,16 +4,24 @@ import numpy as np -from deepmd.infer import DeepPotential -from deepmd.infer import calc_model_devi -from deepmd.infer.model_devi import make_model_devi +from deepmd.infer import ( + DeepPotential, + 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 -from common import gen_data -from common import tests_path +from common import ( + del_data, + gen_data, + 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 d3c166c935..4dcb34bd48 100644 --- a/source/tests/test_model_devi_mix.py +++ b/source/tests/test_model_devi_mix.py @@ -4,18 +4,28 @@ import numpy as np -from deepmd.infer import DeepPotential -from deepmd.infer import calc_model_devi -from deepmd.infer.model_devi import make_model_devi +from deepmd.infer import ( + DeepPotential, + 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 -from common import gen_data -from common import tests_path +from common import ( + del_data, + gen_data, + 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 f267e3d5a3..a6c880046e 100644 --- a/source/tests/test_model_dos.py +++ b/source/tests/test_model_dos.py @@ -1,14 +1,26 @@ import numpy as np -from common import DataSystem -from common import del_data -from common import gen_data -from common import j_loader +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 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 68d53badaa..f33c571ed3 100644 --- a/source/tests/test_model_loc_frame.py +++ b/source/tests/test_model_loc_frame.py @@ -1,13 +1,25 @@ import numpy as np -from common import DataSystem -from common import gen_data -from common import j_loader +from common import ( + DataSystem, + gen_data, + 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 bdd21c28e2..faa682c3a1 100644 --- a/source/tests/test_model_multi.py +++ b/source/tests/test_model_multi.py @@ -1,17 +1,29 @@ import numpy as np -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 +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, +) 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 0ac359c00f..ec88aceac2 100644 --- a/source/tests/test_model_se_a.py +++ b/source/tests/test_model_se_a.py @@ -1,16 +1,30 @@ import dpdata import numpy as np -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 +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, +) 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 b183e2593f..1745ffb642 100644 --- a/source/tests/test_model_se_a_aparam.py +++ b/source/tests/test_model_se_a_aparam.py @@ -1,13 +1,25 @@ import numpy as np -from common import DataSystem -from common import gen_data -from common import j_loader +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.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 52b67135f4..34832e2b5b 100644 --- a/source/tests/test_model_se_a_ebd.py +++ b/source/tests/test_model_se_a_ebd.py @@ -1,13 +1,25 @@ import numpy as np -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 +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, +) 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 e553f07045..bd3e3c0c20 100644 --- a/source/tests/test_model_se_a_fparam.py +++ b/source/tests/test_model_se_a_fparam.py @@ -1,13 +1,25 @@ import numpy as np -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 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, +) 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 af3c0c96b6..36bc955f0a 100644 --- a/source/tests/test_model_se_a_srtab.py +++ b/source/tests/test_model_se_a_srtab.py @@ -1,15 +1,27 @@ import os import numpy as np -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 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, +) 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 4a3f6b6c02..b7e72eb3aa 100644 --- a/source/tests/test_model_se_a_type.py +++ b/source/tests/test_model_se_a_type.py @@ -1,14 +1,28 @@ import numpy as np -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 +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, +) 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 ce44acc886..b473c43c10 100644 --- a/source/tests/test_model_se_atten.py +++ b/source/tests/test_model_se_atten.py @@ -1,17 +1,31 @@ import unittest import numpy as np -from common import DataSystem -from common import gen_data -from common import j_loader +from common import ( + DataSystem, + gen_data, + 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 bab92b8ac5..15771c9ec8 100644 --- a/source/tests/test_model_se_r.py +++ b/source/tests/test_model_se_r.py @@ -1,13 +1,25 @@ import numpy as np -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 +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, +) 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 8bd331e2c5..108baea3fc 100644 --- a/source/tests/test_model_se_t.py +++ b/source/tests/test_model_se_t.py @@ -1,13 +1,25 @@ import numpy as np -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 +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, +) 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 ba1e13b0f2..0bd2856552 100644 --- a/source/tests/test_model_spin.py +++ b/source/tests/test_model_spin.py @@ -1,17 +1,31 @@ import unittest import numpy as np -from common import DataSystem -from common import del_data -from common import gen_data -from common import j_loader +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.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 7cba930c57..64f314759f 100644 --- a/source/tests/test_neighbor_stat.py +++ b/source/tests/test_neighbor_stat.py @@ -4,7 +4,9 @@ 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 752aef452b..9070cad478 100644 --- a/source/tests/test_nvnmd_entrypoints.py +++ b/source/tests/test_nvnmd_entrypoints.py @@ -2,19 +2,37 @@ 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 -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 +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, +) class TestNvnmdFreeze(tf.test.TestCase): diff --git a/source/tests/test_nvnmd_op.py b/source/tests/test_nvnmd_op.py index b99fb64a37..1f54da29c5 100644 --- a/source/tests/test_nvnmd_op.py +++ b/source/tests/test_nvnmd_op.py @@ -2,11 +2,15 @@ import unittest import numpy as np -from common import tests_path - -from deepmd.env import GLOBAL_NP_FLOAT_PRECISION -from deepmd.env import op_module -from deepmd.env import tf +from common import ( + tests_path, +) + +from deepmd.env import ( + GLOBAL_NP_FLOAT_PRECISION, + op_module, + 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 351cb91c36..fcc96ad811 100644 --- a/source/tests/test_nvnmd_se_a.py +++ b/source/tests/test_nvnmd_se_a.py @@ -2,20 +2,32 @@ 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 629a1cc8c8..eafd1b4d6c 100644 --- a/source/tests/test_nvnmd_utils.py +++ b/source/tests/test_nvnmd_utils.py @@ -3,10 +3,18 @@ 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 72dcfb6be9..e2e78bde99 100644 --- a/source/tests/test_parallel_training.py +++ b/source/tests/test_parallel_training.py @@ -2,9 +2,13 @@ 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 22950d610e..30834431c1 100644 --- a/source/tests/test_polar_se_a.py +++ b/source/tests/test_polar_se_a.py @@ -1,15 +1,27 @@ import numpy as np -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 +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, +) 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 c0f5a6a6fe..a60b86a5ea 100644 --- a/source/tests/test_polar_se_a_tebd.py +++ b/source/tests/test_polar_se_a_tebd.py @@ -1,19 +1,33 @@ import unittest import numpy as np -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 common import ( + DataSystem, + finite_difference, + gen_data, + j_loader, + 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 59db7881a1..4dd3b0e52e 100644 --- a/source/tests/test_prod_env_mat.py +++ b/source/tests/test_prod_env_mat.py @@ -1,9 +1,11 @@ import numpy as np -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.env import ( + GLOBAL_NP_FLOAT_PRECISION, + GLOBAL_TF_FLOAT_PRECISION, + op_module, + tf, +) class TestProdEnvMat(tf.test.TestCase): diff --git a/source/tests/test_prod_force.py b/source/tests/test_prod_force.py index 9b1b7f9f20..880a849605 100644 --- a/source/tests/test_prod_force.py +++ b/source/tests/test_prod_force.py @@ -3,9 +3,11 @@ import numpy as np -from deepmd.env import GLOBAL_TF_FLOAT_PRECISION -from deepmd.env import op_module -from deepmd.env import tf +from deepmd.env import ( + GLOBAL_TF_FLOAT_PRECISION, + op_module, + 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 0c649440ab..bfe4f5d12c 100644 --- a/source/tests/test_prod_force_grad.py +++ b/source/tests/test_prod_force_grad.py @@ -1,8 +1,10 @@ import numpy as np -from deepmd.env import GLOBAL_TF_FLOAT_PRECISION -from deepmd.env import op_grads_module -from deepmd.env import tf +from deepmd.env import ( + GLOBAL_TF_FLOAT_PRECISION, + op_grads_module, + tf, +) class TestProdForceGrad(tf.test.TestCase): diff --git a/source/tests/test_prod_virial.py b/source/tests/test_prod_virial.py index 8f8682ea68..d1f7431048 100644 --- a/source/tests/test_prod_virial.py +++ b/source/tests/test_prod_virial.py @@ -1,8 +1,10 @@ import numpy as np -from deepmd.env import GLOBAL_TF_FLOAT_PRECISION -from deepmd.env import op_module -from deepmd.env import tf +from deepmd.env import ( + GLOBAL_TF_FLOAT_PRECISION, + op_module, + 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 5adfff0ea2..ebf019b620 100644 --- a/source/tests/test_prod_virial_grad.py +++ b/source/tests/test_prod_virial_grad.py @@ -1,8 +1,10 @@ import numpy as np -from deepmd.env import GLOBAL_TF_FLOAT_PRECISION -from deepmd.env import op_grads_module -from deepmd.env import tf +from deepmd.env import ( + GLOBAL_TF_FLOAT_PRECISION, + op_grads_module, + tf, +) class TestProdVirialGrad(tf.test.TestCase): diff --git a/source/tests/test_sel_idx.py b/source/tests/test_sel_idx.py index 300f19b689..303897d3b9 100644 --- a/source/tests/test_sel_idx.py +++ b/source/tests/test_sel_idx.py @@ -2,7 +2,9 @@ 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 9394420604..5e042f7225 100644 --- a/source/tests/test_tab_nonsmth.py +++ b/source/tests/test_tab_nonsmth.py @@ -2,18 +2,26 @@ import unittest import numpy as np -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 +from common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) +from test_descrpt_nonsmth import ( + Inter, +) # load grad of force module import deepmd.op # noqa: F401 -from deepmd.env import op_module -from deepmd.env import tf -from deepmd.utils.pair_tab import PairTab +from deepmd.env import ( + op_module, + 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 32e5c1464b..56b0f269c4 100644 --- a/source/tests/test_tab_smooth.py +++ b/source/tests/test_tab_smooth.py @@ -2,17 +2,25 @@ import unittest import numpy as np -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 +from common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) +from test_descrpt_smooth import ( + Inter, +) # load grad of force module -from deepmd.env import op_module -from deepmd.env import tf -from deepmd.utils.pair_tab import PairTab +from deepmd.env import ( + op_module, + 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 d689c9828c..845fb1031e 100644 --- a/source/tests/test_tabulate.py +++ b/source/tests/test_tabulate.py @@ -2,9 +2,13 @@ import numpy as np -from deepmd.common import gelu -from deepmd.env import op_module -from deepmd.env import tf +from deepmd.common import ( + gelu, +) +from deepmd.env import ( + op_module, + 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 4ef724afb8..7f6617a5f1 100644 --- a/source/tests/test_train.py +++ b/source/tests/test_train.py @@ -1,11 +1,15 @@ import unittest -from unittest.mock import patch +from unittest.mock import ( + patch, +) -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 +from deepmd.entrypoints.train import ( + parse_auto_sel, + parse_auto_sel_ratio, + update_one_sel, + update_sel, + wrap_up_4, +) class TestTrain(unittest.TestCase): diff --git a/source/tests/test_transfer.py b/source/tests/test_transfer.py index b2e879e9da..14f88c17dc 100644 --- a/source/tests/test_transfer.py +++ b/source/tests/test_transfer.py @@ -3,12 +3,20 @@ import unittest import numpy as np -from common import run_dp -from common import tests_path +from common import ( + run_dp, + 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 a18881bc2f..87718c1280 100644 --- a/source/tests/test_type_embed.py +++ b/source/tests/test_type_embed.py @@ -1,8 +1,12 @@ import numpy as np -from deepmd.env import tf -from deepmd.utils.type_embed import TypeEmbedNet -from deepmd.utils.type_embed import embed_atom_type +from deepmd.env import ( + tf, +) +from deepmd.utils.type_embed import ( + TypeEmbedNet, + 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 ff4bd2d031..2f6ff81e76 100644 --- a/source/tests/test_type_one_side.py +++ b/source/tests/test_type_one_side.py @@ -1,11 +1,19 @@ import numpy as np -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 +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, +) 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 29b76da614..98ab84cf93 100644 --- a/source/tests/test_virtual_type.py +++ b/source/tests/test_virtual_type.py @@ -3,15 +3,27 @@ import unittest import numpy as np -from common import gen_data -from common import j_loader -from common import tests_path +from common import ( + gen_data, + j_loader, + 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):