Skip to content

Commit

Permalink
Merge branch 'devel' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
anyangml authored Jan 29, 2024
2 parents 451916e + 8900561 commit 0968eaa
Show file tree
Hide file tree
Showing 203 changed files with 552 additions and 480 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ test-command = [
"python -m deepmd -h",
"dp -h",
"dp_ipi",
"pytest {project}/source/tests/test_lammps.py"
"pytest {project}/source/tests/tf/test_lammps.py"
]
test-extras = ["cpu", "test", "lmp", "ipi"]
build = ["cp310-*"]
Expand Down
1 change: 1 addition & 0 deletions source/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
1 change: 1 addition & 0 deletions source/tests/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
5 changes: 5 additions & 0 deletions source/tests/common/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import pathlib

tests_path = pathlib.Path(__file__).parent.absolute()
infer_path = (tests_path.parent / "infer").absolute()
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Union,
)

from deepmd.tf.entrypoints.main import (
from deepmd.main import (
get_ll,
parse_args,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
Path,
)

from deepmd.tf.common import (
from deepmd.common import (
j_loader,
)
from deepmd.tf.utils.argcheck import (
from deepmd.utils.argcheck import (
normalize,
)

p_examples = Path(__file__).parent.parent.parent / "examples"
p_examples = Path(__file__).parent.parent.parent.parent / "examples"

input_files = (
p_examples / "water" / "se_e2_a" / "input.json",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

from deepmd.tf.common import (
from deepmd.common import (
select_idx_map,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
import os
import unittest

from common import (
tests_path,
)

from deepmd.infer.deep_pot import DeepPot as DeepPot
from deepmd.tf.infer.deep_pot import DeepPot as DeepPotTF
from deepmd.tf.utils.convert import (
convert_pbtxt_to_pb,
)

from .common import (
infer_path,
)


class TestUniversalInfer(unittest.TestCase):
@classmethod
def setUpClass(cls):
convert_pbtxt_to_pb(
str(tests_path / os.path.join("infer", "deeppot-r.pbtxt")), "deeppot.pb"
str(infer_path / os.path.join("deeppot-r.pbtxt")), "deeppot.pb"
)

def test_deep_pot(self):
Expand Down
1 change: 1 addition & 0 deletions source/tests/tf/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
1 change: 1 addition & 0 deletions source/tests/common.py → source/tests/tf/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
global_default_places = 5

tests_path = pathlib.Path(__file__).parent.absolute()
infer_path = (tests_path.parent / "infer").absolute()


def j_loader(filename):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

import numpy as np

# from deepmd.tf.entrypoints.compress import compress
from common import (
j_loader,
run_dp,
tests_path,
)

from deepmd.tf.env import (
GLOBAL_NP_FLOAT_PRECISION,
)
from deepmd.tf.infer import (
DeepPot,
)

# from deepmd.tf.entrypoints.compress import compress
from .common import (
j_loader,
run_dp,
tests_path,
)

if GLOBAL_NP_FLOAT_PRECISION == np.float32:
default_places = 4
else:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import os
import unittest

from common import (
j_loader,
)

from deepmd.tf.utils.compat import (
convert_input_v0_v1,
convert_input_v1_v2,
)

from .common import (
j_loader,
)


class TestConvertInput(unittest.TestCase):
def test_convert_smth(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
import os
import unittest

# from deepmd.tf.entrypoints.compress import compress
from common import (
j_loader,
run_dp,
tests_path,
)
from packaging.version import parse as parse_version

from deepmd.tf.env import (
tf,
)

# from deepmd.tf.entrypoints.compress import compress
from .common import (
j_loader,
run_dp,
tests_path,
)


@unittest.skipIf(
parse_version(tf.__version__) < parse_version("2"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
import unittest

import numpy as np
from common import (
gen_data,
j_loader,
)
from packaging.version import parse as parse_version

from deepmd.tf.common import (
Expand All @@ -31,6 +27,11 @@
TypeEmbedNet,
)

from .common import (
gen_data,
j_loader,
)

GLOBAL_ENER_FLOAT_PRECISION = tf.float64
GLOBAL_TF_FLOAT_PRECISION = tf.float64
GLOBAL_NP_FLOAT_PRECISION = np.float64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
import os

import numpy as np
from common import (
Data,
j_loader,
tests_path,
)

from deepmd.tf.common import (
data_requirement,
Expand All @@ -29,6 +24,12 @@
DeepmdDataSystem,
)

from .common import (
Data,
j_loader,
tests_path,
)

if GLOBAL_NP_FLOAT_PRECISION == np.float32:
global_default_fv_hh = 1e-2
global_default_dw_hh = 1e-2
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

import ase.neighborlist
import numpy as np
from common import (
finite_difference,
strerch_box,
tests_path,
tf,
)
from packaging.version import parse as parse_version

from deepmd.tf.env import (
Expand All @@ -22,6 +16,13 @@
convert_pbtxt_to_pb,
)

from .common import (
finite_difference,
infer_path,
strerch_box,
tf,
)

if GLOBAL_NP_FLOAT_PRECISION == np.float32:
default_places = 4
else:
Expand All @@ -32,7 +33,7 @@ class TestDeepDipolePBC(unittest.TestCase):
@classmethod
def setUpClass(cls):
convert_pbtxt_to_pb(
str(tests_path / os.path.join("infer", "deepdipole.pbtxt")), "deepdipole.pb"
str(infer_path / os.path.join("deepdipole.pbtxt")), "deepdipole.pb"
)
cls.dp = DeepDipole("deepdipole.pb")

Expand Down Expand Up @@ -111,7 +112,7 @@ class TestDeepDipoleNoPBC(unittest.TestCase):
@classmethod
def setUpClass(cls):
convert_pbtxt_to_pb(
str(tests_path / os.path.join("infer", "deepdipole.pbtxt")), "deepdipole.pb"
str(infer_path / os.path.join("deepdipole.pbtxt")), "deepdipole.pb"
)
cls.dp = DeepDipole("deepdipole.pb")

Expand Down Expand Up @@ -185,7 +186,7 @@ class TestDeepDipoleNewPBC(unittest.TestCase):
@classmethod
def setUpClass(cls):
convert_pbtxt_to_pb(
str(tests_path / os.path.join("infer", "deepdipole_new.pbtxt")),
str(infer_path / os.path.join("deepdipole_new.pbtxt")),
"deepdipole_new.pb",
)
cls.dp = DeepDipole("deepdipole_new.pb")
Expand Down Expand Up @@ -656,7 +657,7 @@ class TestDeepDipoleFakePBC(unittest.TestCase):
@classmethod
def setUpClass(cls):
convert_pbtxt_to_pb(
str(tests_path / os.path.join("infer", "deepdipole_fake.pbtxt")),
str(infer_path / os.path.join("deepdipole_fake.pbtxt")),
"deepdipole_fake.pb",
)
cls.dp = DeepDipole("deepdipole_fake.pb")
Expand Down Expand Up @@ -1042,7 +1043,7 @@ class TestDeepDipoleNewPBCNeighborList(TestDeepDipoleNewPBC):
@classmethod
def setUpClass(cls):
convert_pbtxt_to_pb(
str(tests_path / os.path.join("infer", "deepdipole_new.pbtxt")),
str(infer_path / os.path.join("deepdipole_new.pbtxt")),
"deepdipole_new.pb",
)
cls.dp = DeepDipole(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import unittest

import numpy as np
from common import (
tests_path,
)

from deepmd.tf.env import (
GLOBAL_NP_FLOAT_PRECISION,
Expand All @@ -17,6 +14,10 @@
convert_pbtxt_to_pb,
)

from .common import (
infer_path,
)

if GLOBAL_NP_FLOAT_PRECISION == np.float32:
default_places = 4
else:
Expand All @@ -27,7 +28,7 @@ class TestDeepDOS(unittest.TestCase):
@classmethod
def setUpClass(cls):
convert_pbtxt_to_pb(
str(tests_path / os.path.join("infer", "deepdos.pbtxt")), "deepdos.pb"
str(infer_path / os.path.join("deepdos.pbtxt")), "deepdos.pb"
)
cls.dp = DeepDOS("deepdos.pb")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import unittest

import numpy as np
from common import (
tests_path,
)

from deepmd.tf.env import (
GLOBAL_NP_FLOAT_PRECISION,
Expand All @@ -16,6 +13,10 @@
DeepmdData,
)

from .common import (
tests_path,
)

if GLOBAL_NP_FLOAT_PRECISION == np.float32:
places = 6
else:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

import ase.neighborlist
import numpy as np
from common import (
tests_path,
tf,
)
from packaging.version import parse as parse_version

from deepmd.tf.env import (
Expand All @@ -20,6 +16,11 @@
convert_pbtxt_to_pb,
)

from .common import (
infer_path,
tf,
)

if GLOBAL_NP_FLOAT_PRECISION == np.float32:
default_places = 4
else:
Expand All @@ -30,7 +31,7 @@ class TestDeepPolarPBC(unittest.TestCase):
@classmethod
def setUpClass(cls):
convert_pbtxt_to_pb(
str(tests_path / os.path.join("infer", "deeppolar.pbtxt")), "deeppolar.pb"
str(infer_path / os.path.join("deeppolar.pbtxt")), "deeppolar.pb"
)
cls.dp = DeepPolar("deeppolar.pb")

Expand Down Expand Up @@ -121,7 +122,7 @@ class TestDeepPolarNoPBC(unittest.TestCase):
@classmethod
def setUpClass(cls):
convert_pbtxt_to_pb(
str(tests_path / os.path.join("infer", "deeppolar.pbtxt")), "deeppolar.pb"
str(infer_path / os.path.join("deeppolar.pbtxt")), "deeppolar.pb"
)
cls.dp = DeepPolar("deeppolar.pb")

Expand Down Expand Up @@ -207,7 +208,7 @@ class TestDeepPolarNewPBC(unittest.TestCase):
@classmethod
def setUpClass(cls):
convert_pbtxt_to_pb(
str(tests_path / os.path.join("infer", "deeppolar_new.pbtxt")),
str(infer_path / os.path.join("deeppolar_new.pbtxt")),
"deeppolar_new.pb",
)
cls.dp = DeepPolar("deeppolar_new.pb")
Expand Down Expand Up @@ -1093,7 +1094,7 @@ class TestDeepPolarNewPBCNeighborList(unittest.TestCase):
@classmethod
def setUpClass(cls):
convert_pbtxt_to_pb(
str(tests_path / os.path.join("infer", "deeppolar_new.pbtxt")),
str(infer_path / os.path.join("deeppolar_new.pbtxt")),
"deeppolar_new.pb",
)
cls.dp = DeepPolar(
Expand Down
Loading

0 comments on commit 0968eaa

Please sign in to comment.