Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 29, 2023
1 parent ceb698b commit faca64b
Show file tree
Hide file tree
Showing 217 changed files with 3,134 additions and 1,409 deletions.
8 changes: 6 additions & 2 deletions backend/dp_backend.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 22 additions & 10 deletions backend/find_tensorflow.py
Original file line number Diff line number Diff line change
@@ -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]]:
Expand Down
8 changes: 6 additions & 2 deletions data/json/json2yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 24 additions & 12 deletions deepmd/__init__.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 3 additions & 1 deletion deepmd/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Package dp entry point."""

from .entrypoints.main import main
from .entrypoints.main import (
main,
)

if __name__ == "__main__":
main()
36 changes: 23 additions & 13 deletions deepmd/calculator.py
Original file line number Diff line number Diff line change
@@ -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"]

Expand Down
8 changes: 5 additions & 3 deletions deepmd/cluster/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 9 additions & 5 deletions deepmd/cluster/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
12 changes: 8 additions & 4 deletions deepmd/cluster/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
1 change: 0 additions & 1 deletion deepmd/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from deepmd.env import (
GLOBAL_NP_FLOAT_PRECISION,
GLOBAL_PD_FLOAT_PRECISION,
GLOBAL_TF_FLOAT_PRECISION,
op_module,
paddle,
tf,
Expand Down
42 changes: 31 additions & 11 deletions deepmd/descriptor/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
30 changes: 19 additions & 11 deletions deepmd/descriptor/descriptor.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
22 changes: 15 additions & 7 deletions deepmd/descriptor/hybrid.py
Original file line number Diff line number Diff line change
@@ -1,20 +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_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
# from deepmd.descriptor import DescrptSeT
# 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")
Expand Down
32 changes: 21 additions & 11 deletions deepmd/descriptor/loc_frame.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
Loading

0 comments on commit faca64b

Please sign in to comment.