diff --git a/pyproject.toml b/pyproject.toml index 6c8632ddb9..1d37246a88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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-*"] diff --git a/source/tests/__init__.py b/source/tests/__init__.py new file mode 100644 index 0000000000..6ceb116d85 --- /dev/null +++ b/source/tests/__init__.py @@ -0,0 +1 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/source/tests/common/__init__.py b/source/tests/common/__init__.py new file mode 100644 index 0000000000..6ceb116d85 --- /dev/null +++ b/source/tests/common/__init__.py @@ -0,0 +1 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/source/tests/common/common.py b/source/tests/common/common.py new file mode 100644 index 0000000000..4736042150 --- /dev/null +++ b/source/tests/common/common.py @@ -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() diff --git a/source/tests/test_argument_parser.py b/source/tests/common/test_argument_parser.py similarity index 99% rename from source/tests/test_argument_parser.py rename to source/tests/common/test_argument_parser.py index 988199d1e4..0b4f053aed 100644 --- a/source/tests/test_argument_parser.py +++ b/source/tests/common/test_argument_parser.py @@ -21,7 +21,7 @@ Union, ) -from deepmd.tf.entrypoints.main import ( +from deepmd.main import ( get_ll, parse_args, ) diff --git a/source/tests/test_examples.py b/source/tests/common/test_examples.py similarity index 93% rename from source/tests/test_examples.py rename to source/tests/common/test_examples.py index ea087fbc9d..ad06925eab 100644 --- a/source/tests/test_examples.py +++ b/source/tests/common/test_examples.py @@ -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", diff --git a/source/tests/test_gui.py b/source/tests/common/test_gui.py similarity index 100% rename from source/tests/test_gui.py rename to source/tests/common/test_gui.py diff --git a/source/tests/test_model_format_utils.py b/source/tests/common/test_model_format_utils.py similarity index 100% rename from source/tests/test_model_format_utils.py rename to source/tests/common/test_model_format_utils.py diff --git a/source/tests/test_output_def.py b/source/tests/common/test_output_def.py similarity index 100% rename from source/tests/test_output_def.py rename to source/tests/common/test_output_def.py diff --git a/source/tests/test_sel_idx.py b/source/tests/common/test_sel_idx.py similarity index 94% rename from source/tests/test_sel_idx.py rename to source/tests/common/test_sel_idx.py index e340ba55e7..d6630e3e83 100644 --- a/source/tests/test_sel_idx.py +++ b/source/tests/common/test_sel_idx.py @@ -3,7 +3,7 @@ import numpy as np -from deepmd.tf.common import ( +from deepmd.common import ( select_idx_map, ) diff --git a/source/tests/test_uni_infer.py b/source/tests/common/test_uni_infer.py similarity index 81% rename from source/tests/test_uni_infer.py rename to source/tests/common/test_uni_infer.py index 4cff5e10d5..139d1f9ec9 100644 --- a/source/tests/test_uni_infer.py +++ b/source/tests/common/test_uni_infer.py @@ -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): diff --git a/source/tests/tf/__init__.py b/source/tests/tf/__init__.py new file mode 100644 index 0000000000..6ceb116d85 --- /dev/null +++ b/source/tests/tf/__init__.py @@ -0,0 +1 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/source/tests/common.py b/source/tests/tf/common.py similarity index 99% rename from source/tests/common.py rename to source/tests/tf/common.py index cb68e4d46d..a83397c11c 100644 --- a/source/tests/common.py +++ b/source/tests/tf/common.py @@ -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): diff --git a/source/tests/compat_inputs/water_se_a_v0.json b/source/tests/tf/compat_inputs/water_se_a_v0.json similarity index 100% rename from source/tests/compat_inputs/water_se_a_v0.json rename to source/tests/tf/compat_inputs/water_se_a_v0.json diff --git a/source/tests/compat_inputs/water_se_a_v1.json b/source/tests/tf/compat_inputs/water_se_a_v1.json similarity index 100% rename from source/tests/compat_inputs/water_se_a_v1.json rename to source/tests/tf/compat_inputs/water_se_a_v1.json diff --git a/source/tests/compat_inputs/water_v0.json b/source/tests/tf/compat_inputs/water_v0.json similarity index 100% rename from source/tests/compat_inputs/water_v0.json rename to source/tests/tf/compat_inputs/water_v0.json diff --git a/source/tests/compat_inputs/water_v1.json b/source/tests/tf/compat_inputs/water_v1.json similarity index 100% rename from source/tests/compat_inputs/water_v1.json rename to source/tests/tf/compat_inputs/water_v1.json diff --git a/source/tests/compat_inputs/water_v2.json b/source/tests/tf/compat_inputs/water_v2.json similarity index 100% rename from source/tests/compat_inputs/water_v2.json rename to source/tests/tf/compat_inputs/water_v2.json diff --git a/source/tests/data_dp_mask/nopbc b/source/tests/tf/data_dp_mask/nopbc similarity index 100% rename from source/tests/data_dp_mask/nopbc rename to source/tests/tf/data_dp_mask/nopbc diff --git a/source/tests/data_dp_mask/set.000/aparam.npy b/source/tests/tf/data_dp_mask/set.000/aparam.npy similarity index 100% rename from source/tests/data_dp_mask/set.000/aparam.npy rename to source/tests/tf/data_dp_mask/set.000/aparam.npy diff --git a/source/tests/data_dp_mask/set.000/atom_pref.npy b/source/tests/tf/data_dp_mask/set.000/atom_pref.npy similarity index 100% rename from source/tests/data_dp_mask/set.000/atom_pref.npy rename to source/tests/tf/data_dp_mask/set.000/atom_pref.npy diff --git a/source/tests/data_dp_mask/set.000/box.npy b/source/tests/tf/data_dp_mask/set.000/box.npy similarity index 100% rename from source/tests/data_dp_mask/set.000/box.npy rename to source/tests/tf/data_dp_mask/set.000/box.npy diff --git a/source/tests/data_dp_mask/set.000/coord.npy b/source/tests/tf/data_dp_mask/set.000/coord.npy similarity index 100% rename from source/tests/data_dp_mask/set.000/coord.npy rename to source/tests/tf/data_dp_mask/set.000/coord.npy diff --git a/source/tests/data_dp_mask/set.000/energy.npy b/source/tests/tf/data_dp_mask/set.000/energy.npy similarity index 100% rename from source/tests/data_dp_mask/set.000/energy.npy rename to source/tests/tf/data_dp_mask/set.000/energy.npy diff --git a/source/tests/data_dp_mask/set.000/force.npy b/source/tests/tf/data_dp_mask/set.000/force.npy similarity index 100% rename from source/tests/data_dp_mask/set.000/force.npy rename to source/tests/tf/data_dp_mask/set.000/force.npy diff --git a/source/tests/data_dp_mask/type.raw b/source/tests/tf/data_dp_mask/type.raw similarity index 100% rename from source/tests/data_dp_mask/type.raw rename to source/tests/tf/data_dp_mask/type.raw diff --git a/source/tests/data_dp_mask/type_map.raw b/source/tests/tf/data_dp_mask/type_map.raw similarity index 100% rename from source/tests/data_dp_mask/type_map.raw rename to source/tests/tf/data_dp_mask/type_map.raw diff --git a/source/tests/data_modifier/dipole.json b/source/tests/tf/data_modifier/dipole.json similarity index 100% rename from source/tests/data_modifier/dipole.json rename to source/tests/tf/data_modifier/dipole.json diff --git a/source/tests/data_modifier/sys_10/set.000/atomic_dipole.npy b/source/tests/tf/data_modifier/sys_10/set.000/atomic_dipole.npy similarity index 100% rename from source/tests/data_modifier/sys_10/set.000/atomic_dipole.npy rename to source/tests/tf/data_modifier/sys_10/set.000/atomic_dipole.npy diff --git a/source/tests/data_modifier/sys_10/set.000/box.npy b/source/tests/tf/data_modifier/sys_10/set.000/box.npy similarity index 100% rename from source/tests/data_modifier/sys_10/set.000/box.npy rename to source/tests/tf/data_modifier/sys_10/set.000/box.npy diff --git a/source/tests/data_modifier/sys_10/set.000/coord.npy b/source/tests/tf/data_modifier/sys_10/set.000/coord.npy similarity index 100% rename from source/tests/data_modifier/sys_10/set.000/coord.npy rename to source/tests/tf/data_modifier/sys_10/set.000/coord.npy diff --git a/source/tests/data_modifier/sys_10/set.000/energy.npy b/source/tests/tf/data_modifier/sys_10/set.000/energy.npy similarity index 100% rename from source/tests/data_modifier/sys_10/set.000/energy.npy rename to source/tests/tf/data_modifier/sys_10/set.000/energy.npy diff --git a/source/tests/data_modifier/sys_10/set.000/force.npy b/source/tests/tf/data_modifier/sys_10/set.000/force.npy similarity index 100% rename from source/tests/data_modifier/sys_10/set.000/force.npy rename to source/tests/tf/data_modifier/sys_10/set.000/force.npy diff --git a/source/tests/data_modifier/sys_10/type.raw b/source/tests/tf/data_modifier/sys_10/type.raw similarity index 100% rename from source/tests/data_modifier/sys_10/type.raw rename to source/tests/tf/data_modifier/sys_10/type.raw diff --git a/source/tests/data_modifier/sys_10/type_map.raw b/source/tests/tf/data_modifier/sys_10/type_map.raw similarity index 100% rename from source/tests/data_modifier/sys_10/type_map.raw rename to source/tests/tf/data_modifier/sys_10/type_map.raw diff --git a/source/tests/finetune/data/set.000/box.npy b/source/tests/tf/finetune/data/set.000/box.npy similarity index 100% rename from source/tests/finetune/data/set.000/box.npy rename to source/tests/tf/finetune/data/set.000/box.npy diff --git a/source/tests/finetune/data/set.000/coord.npy b/source/tests/tf/finetune/data/set.000/coord.npy similarity index 100% rename from source/tests/finetune/data/set.000/coord.npy rename to source/tests/tf/finetune/data/set.000/coord.npy diff --git a/source/tests/finetune/data/set.000/energy.npy b/source/tests/tf/finetune/data/set.000/energy.npy similarity index 100% rename from source/tests/finetune/data/set.000/energy.npy rename to source/tests/tf/finetune/data/set.000/energy.npy diff --git a/source/tests/finetune/data/set.000/force.npy b/source/tests/tf/finetune/data/set.000/force.npy similarity index 100% rename from source/tests/finetune/data/set.000/force.npy rename to source/tests/tf/finetune/data/set.000/force.npy diff --git a/source/tests/finetune/data/type.raw b/source/tests/tf/finetune/data/type.raw similarity index 100% rename from source/tests/finetune/data/type.raw rename to source/tests/tf/finetune/data/type.raw diff --git a/source/tests/finetune/data/type_map.raw b/source/tests/tf/finetune/data/type_map.raw similarity index 100% rename from source/tests/finetune/data/type_map.raw rename to source/tests/tf/finetune/data/type_map.raw diff --git a/source/tests/finetune/data_mixed_type/set.000/box.npy b/source/tests/tf/finetune/data_mixed_type/set.000/box.npy similarity index 100% rename from source/tests/finetune/data_mixed_type/set.000/box.npy rename to source/tests/tf/finetune/data_mixed_type/set.000/box.npy diff --git a/source/tests/finetune/data_mixed_type/set.000/coord.npy b/source/tests/tf/finetune/data_mixed_type/set.000/coord.npy similarity index 100% rename from source/tests/finetune/data_mixed_type/set.000/coord.npy rename to source/tests/tf/finetune/data_mixed_type/set.000/coord.npy diff --git a/source/tests/finetune/data_mixed_type/set.000/energy.npy b/source/tests/tf/finetune/data_mixed_type/set.000/energy.npy similarity index 100% rename from source/tests/finetune/data_mixed_type/set.000/energy.npy rename to source/tests/tf/finetune/data_mixed_type/set.000/energy.npy diff --git a/source/tests/finetune/data_mixed_type/set.000/force.npy b/source/tests/tf/finetune/data_mixed_type/set.000/force.npy similarity index 100% rename from source/tests/finetune/data_mixed_type/set.000/force.npy rename to source/tests/tf/finetune/data_mixed_type/set.000/force.npy diff --git a/source/tests/finetune/data_mixed_type/set.000/real_atom_types.npy b/source/tests/tf/finetune/data_mixed_type/set.000/real_atom_types.npy similarity index 100% rename from source/tests/finetune/data_mixed_type/set.000/real_atom_types.npy rename to source/tests/tf/finetune/data_mixed_type/set.000/real_atom_types.npy diff --git a/source/tests/finetune/data_mixed_type/type.raw b/source/tests/tf/finetune/data_mixed_type/type.raw similarity index 100% rename from source/tests/finetune/data_mixed_type/type.raw rename to source/tests/tf/finetune/data_mixed_type/type.raw diff --git a/source/tests/finetune/data_mixed_type/type_map.raw b/source/tests/tf/finetune/data_mixed_type/type_map.raw similarity index 100% rename from source/tests/finetune/data_mixed_type/type_map.raw rename to source/tests/tf/finetune/data_mixed_type/type_map.raw diff --git a/source/tests/finetune/input_finetune.json b/source/tests/tf/finetune/input_finetune.json similarity index 100% rename from source/tests/finetune/input_finetune.json rename to source/tests/tf/finetune/input_finetune.json diff --git a/source/tests/finetune/input_pretrain.json b/source/tests/tf/finetune/input_pretrain.json similarity index 100% rename from source/tests/finetune/input_pretrain.json rename to source/tests/tf/finetune/input_pretrain.json diff --git a/source/tests/init_frz_model/data/set.000/box.npy b/source/tests/tf/init_frz_model/data/set.000/box.npy similarity index 100% rename from source/tests/init_frz_model/data/set.000/box.npy rename to source/tests/tf/init_frz_model/data/set.000/box.npy diff --git a/source/tests/init_frz_model/data/set.000/coord.npy b/source/tests/tf/init_frz_model/data/set.000/coord.npy similarity index 100% rename from source/tests/init_frz_model/data/set.000/coord.npy rename to source/tests/tf/init_frz_model/data/set.000/coord.npy diff --git a/source/tests/init_frz_model/data/set.000/energy.npy b/source/tests/tf/init_frz_model/data/set.000/energy.npy similarity index 100% rename from source/tests/init_frz_model/data/set.000/energy.npy rename to source/tests/tf/init_frz_model/data/set.000/energy.npy diff --git a/source/tests/init_frz_model/data/set.000/force.npy b/source/tests/tf/init_frz_model/data/set.000/force.npy similarity index 100% rename from source/tests/init_frz_model/data/set.000/force.npy rename to source/tests/tf/init_frz_model/data/set.000/force.npy diff --git a/source/tests/init_frz_model/data/type.raw b/source/tests/tf/init_frz_model/data/type.raw similarity index 100% rename from source/tests/init_frz_model/data/type.raw rename to source/tests/tf/init_frz_model/data/type.raw diff --git a/source/tests/init_frz_model/data/type_map.raw b/source/tests/tf/init_frz_model/data/type_map.raw similarity index 100% rename from source/tests/init_frz_model/data/type_map.raw rename to source/tests/tf/init_frz_model/data/type_map.raw diff --git a/source/tests/init_frz_model/input.json b/source/tests/tf/init_frz_model/input.json similarity index 100% rename from source/tests/init_frz_model/input.json rename to source/tests/tf/init_frz_model/input.json diff --git a/source/tests/model_compression/data/set.000/box.npy b/source/tests/tf/model_compression/data/set.000/box.npy similarity index 100% rename from source/tests/model_compression/data/set.000/box.npy rename to source/tests/tf/model_compression/data/set.000/box.npy diff --git a/source/tests/model_compression/data/set.000/coord.npy b/source/tests/tf/model_compression/data/set.000/coord.npy similarity index 100% rename from source/tests/model_compression/data/set.000/coord.npy rename to source/tests/tf/model_compression/data/set.000/coord.npy diff --git a/source/tests/model_compression/data/set.000/energy.npy b/source/tests/tf/model_compression/data/set.000/energy.npy similarity index 100% rename from source/tests/model_compression/data/set.000/energy.npy rename to source/tests/tf/model_compression/data/set.000/energy.npy diff --git a/source/tests/model_compression/data/set.000/force.npy b/source/tests/tf/model_compression/data/set.000/force.npy similarity index 100% rename from source/tests/model_compression/data/set.000/force.npy rename to source/tests/tf/model_compression/data/set.000/force.npy diff --git a/source/tests/model_compression/data/type.raw b/source/tests/tf/model_compression/data/type.raw similarity index 100% rename from source/tests/model_compression/data/type.raw rename to source/tests/tf/model_compression/data/type.raw diff --git a/source/tests/model_compression/data/type_map.raw b/source/tests/tf/model_compression/data/type_map.raw similarity index 100% rename from source/tests/model_compression/data/type_map.raw rename to source/tests/tf/model_compression/data/type_map.raw diff --git a/source/tests/model_compression/input.json b/source/tests/tf/model_compression/input.json similarity index 100% rename from source/tests/model_compression/input.json rename to source/tests/tf/model_compression/input.json diff --git a/source/tests/model_spin/set.000/box.npy b/source/tests/tf/model_spin/set.000/box.npy similarity index 100% rename from source/tests/model_spin/set.000/box.npy rename to source/tests/tf/model_spin/set.000/box.npy diff --git a/source/tests/model_spin/set.000/coord.npy b/source/tests/tf/model_spin/set.000/coord.npy similarity index 100% rename from source/tests/model_spin/set.000/coord.npy rename to source/tests/tf/model_spin/set.000/coord.npy diff --git a/source/tests/model_spin/set.000/energy.npy b/source/tests/tf/model_spin/set.000/energy.npy similarity index 100% rename from source/tests/model_spin/set.000/energy.npy rename to source/tests/tf/model_spin/set.000/energy.npy diff --git a/source/tests/model_spin/set.000/force.npy b/source/tests/tf/model_spin/set.000/force.npy similarity index 100% rename from source/tests/model_spin/set.000/force.npy rename to source/tests/tf/model_spin/set.000/force.npy diff --git a/source/tests/model_spin/type.raw b/source/tests/tf/model_spin/type.raw similarity index 100% rename from source/tests/model_spin/type.raw rename to source/tests/tf/model_spin/type.raw diff --git a/source/tests/nvnmd/ref/box.npy b/source/tests/tf/nvnmd/ref/box.npy similarity index 100% rename from source/tests/nvnmd/ref/box.npy rename to source/tests/tf/nvnmd/ref/box.npy diff --git a/source/tests/nvnmd/ref/config_v0_cnn.npy b/source/tests/tf/nvnmd/ref/config_v0_cnn.npy similarity index 100% rename from source/tests/nvnmd/ref/config_v0_cnn.npy rename to source/tests/tf/nvnmd/ref/config_v0_cnn.npy diff --git a/source/tests/nvnmd/ref/config_v1_cnn.npy b/source/tests/tf/nvnmd/ref/config_v1_cnn.npy similarity index 100% rename from source/tests/nvnmd/ref/config_v1_cnn.npy rename to source/tests/tf/nvnmd/ref/config_v1_cnn.npy diff --git a/source/tests/nvnmd/ref/coord.npy b/source/tests/tf/nvnmd/ref/coord.npy similarity index 100% rename from source/tests/nvnmd/ref/coord.npy rename to source/tests/tf/nvnmd/ref/coord.npy diff --git a/source/tests/nvnmd/ref/type.raw b/source/tests/tf/nvnmd/ref/type.raw similarity index 100% rename from source/tests/nvnmd/ref/type.raw rename to source/tests/tf/nvnmd/ref/type.raw diff --git a/source/tests/nvnmd/ref/weight_v0_cnn.npy b/source/tests/tf/nvnmd/ref/weight_v0_cnn.npy similarity index 100% rename from source/tests/nvnmd/ref/weight_v0_cnn.npy rename to source/tests/tf/nvnmd/ref/weight_v0_cnn.npy diff --git a/source/tests/nvnmd/ref/weight_v1_cnn.npy b/source/tests/tf/nvnmd/ref/weight_v1_cnn.npy similarity index 100% rename from source/tests/nvnmd/ref/weight_v1_cnn.npy rename to source/tests/tf/nvnmd/ref/weight_v1_cnn.npy diff --git a/source/tests/pairwise_dprc.json b/source/tests/tf/pairwise_dprc.json similarity index 100% rename from source/tests/pairwise_dprc.json rename to source/tests/tf/pairwise_dprc.json diff --git a/source/tests/polar_se_a.json b/source/tests/tf/polar_se_a.json similarity index 100% rename from source/tests/polar_se_a.json rename to source/tests/tf/polar_se_a.json diff --git a/source/tests/polar_se_a_tebd.json b/source/tests/tf/polar_se_a_tebd.json similarity index 100% rename from source/tests/polar_se_a_tebd.json rename to source/tests/tf/polar_se_a_tebd.json diff --git a/source/tests/test.hdf5 b/source/tests/tf/test.hdf5 similarity index 100% rename from source/tests/test.hdf5 rename to source/tests/tf/test.hdf5 diff --git a/source/tests/test_activation_fn_gelu.py b/source/tests/tf/test_activation_fn_gelu.py similarity index 100% rename from source/tests/test_activation_fn_gelu.py rename to source/tests/tf/test_activation_fn_gelu.py diff --git a/source/tests/test_adjust_sel.py b/source/tests/tf/test_adjust_sel.py similarity index 99% rename from source/tests/test_adjust_sel.py rename to source/tests/tf/test_adjust_sel.py index 9bed3606fd..c86bad45b7 100644 --- a/source/tests/test_adjust_sel.py +++ b/source/tests/tf/test_adjust_sel.py @@ -6,13 +6,6 @@ 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, ) @@ -20,6 +13,13 @@ 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: diff --git a/source/tests/test_auto_batch_size.py b/source/tests/tf/test_auto_batch_size.py similarity index 100% rename from source/tests/test_auto_batch_size.py rename to source/tests/tf/test_auto_batch_size.py diff --git a/source/tests/test_cluster.py b/source/tests/tf/test_cluster.py similarity index 100% rename from source/tests/test_cluster.py rename to source/tests/tf/test_cluster.py diff --git a/source/tests/test_common.py b/source/tests/tf/test_common.py similarity index 100% rename from source/tests/test_common.py rename to source/tests/tf/test_common.py diff --git a/source/tests/test_compat_input.py b/source/tests/tf/test_compat_input.py similarity index 98% rename from source/tests/test_compat_input.py rename to source/tests/tf/test_compat_input.py index e8a74e9c48..f7c605380c 100644 --- a/source/tests/test_compat_input.py +++ b/source/tests/tf/test_compat_input.py @@ -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): diff --git a/source/tests/test_compressed_training.py b/source/tests/tf/test_compressed_training.py similarity index 99% rename from source/tests/test_compressed_training.py rename to source/tests/tf/test_compressed_training.py index c3d07762f8..998ef8cb59 100644 --- a/source/tests/test_compressed_training.py +++ b/source/tests/tf/test_compressed_training.py @@ -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"), diff --git a/source/tests/test_data_large_batch.py b/source/tests/tf/test_data_large_batch.py similarity index 99% rename from source/tests/test_data_large_batch.py rename to source/tests/tf/test_data_large_batch.py index 84e99591d5..c31a4c4a9a 100644 --- a/source/tests/test_data_large_batch.py +++ b/source/tests/tf/test_data_large_batch.py @@ -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 ( @@ -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 diff --git a/source/tests/test_data_modifier.py b/source/tests/tf/test_data_modifier.py similarity index 99% rename from source/tests/test_data_modifier.py rename to source/tests/tf/test_data_modifier.py index 01e3cdcb2d..98b6c41427 100644 --- a/source/tests/test_data_modifier.py +++ b/source/tests/tf/test_data_modifier.py @@ -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, @@ -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 diff --git a/source/tests/test_data_modifier_shuffle.py b/source/tests/tf/test_data_modifier_shuffle.py similarity index 100% rename from source/tests/test_data_modifier_shuffle.py rename to source/tests/tf/test_data_modifier_shuffle.py diff --git a/source/tests/test_data_requirement.py b/source/tests/tf/test_data_requirement.py similarity index 100% rename from source/tests/test_data_requirement.py rename to source/tests/tf/test_data_requirement.py diff --git a/source/tests/test_deepdipole.py b/source/tests/tf/test_deepdipole.py similarity index 98% rename from source/tests/test_deepdipole.py rename to source/tests/tf/test_deepdipole.py index 6dffe59fe5..2c8ec7cc66 100644 --- a/source/tests/test_deepdipole.py +++ b/source/tests/tf/test_deepdipole.py @@ -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 ( @@ -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: @@ -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") @@ -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") @@ -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") @@ -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") @@ -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( diff --git a/source/tests/test_deepdos.py b/source/tests/tf/test_deepdos.py similarity index 99% rename from source/tests/test_deepdos.py rename to source/tests/tf/test_deepdos.py index 3f3d0cda7f..d94c2c3f2d 100644 --- a/source/tests/test_deepdos.py +++ b/source/tests/tf/test_deepdos.py @@ -3,9 +3,6 @@ import unittest import numpy as np -from common import ( - tests_path, -) from deepmd.tf.env import ( GLOBAL_NP_FLOAT_PRECISION, @@ -17,6 +14,10 @@ convert_pbtxt_to_pb, ) +from .common import ( + infer_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: @@ -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") diff --git a/source/tests/test_deepmd_data.py b/source/tests/tf/test_deepmd_data.py similarity index 99% rename from source/tests/test_deepmd_data.py rename to source/tests/tf/test_deepmd_data.py index e486446ab8..b1a0147771 100644 --- a/source/tests/test_deepmd_data.py +++ b/source/tests/tf/test_deepmd_data.py @@ -5,9 +5,6 @@ import unittest import numpy as np -from common import ( - tests_path, -) from deepmd.tf.env import ( GLOBAL_NP_FLOAT_PRECISION, @@ -16,6 +13,10 @@ DeepmdData, ) +from .common import ( + tests_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: places = 6 else: diff --git a/source/tests/test_deepmd_data_sys.py b/source/tests/tf/test_deepmd_data_sys.py similarity index 100% rename from source/tests/test_deepmd_data_sys.py rename to source/tests/tf/test_deepmd_data_sys.py diff --git a/source/tests/test_deeppolar.py b/source/tests/tf/test_deeppolar.py similarity index 99% rename from source/tests/test_deeppolar.py rename to source/tests/tf/test_deeppolar.py index 18d9cb4ad9..cfa115c59f 100644 --- a/source/tests/test_deeppolar.py +++ b/source/tests/tf/test_deeppolar.py @@ -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 ( @@ -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: @@ -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") @@ -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") @@ -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") @@ -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( diff --git a/source/tests/test_deeppot_a.py b/source/tests/tf/test_deeppot_a.py similarity index 97% rename from source/tests/test_deeppot_a.py rename to source/tests/tf/test_deeppot_a.py index 32e92cd8bd..af060aca1c 100644 --- a/source/tests/test_deeppot_a.py +++ b/source/tests/tf/test_deeppot_a.py @@ -6,10 +6,6 @@ import ase.neighborlist import dpdata import numpy as np -from common import ( - run_dp, - tests_path, -) from packaging.version import parse as parse_version from deepmd.tf.env import ( @@ -30,6 +26,12 @@ detect_model_version, ) +from .common import ( + infer_path, + run_dp, + tests_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: @@ -38,7 +40,7 @@ class TestModelMajorCompatability(unittest.TestCase): def setUp(self): - model_file = str(tests_path / os.path.join("infer", "deeppot.pbtxt")) + model_file = str(infer_path / os.path.join("deeppot.pbtxt")) with open(model_file) as fp: # data = fp.read().replace('\n', '') data = fp.read().split("\n") @@ -68,7 +70,7 @@ def test(self): class TestModelMinorCompatability(unittest.TestCase): def setUp(self): - model_file = str(tests_path / os.path.join("infer", "deeppot.pbtxt")) + model_file = str(infer_path / os.path.join("deeppot.pbtxt")) with open(model_file) as fp: # data = fp.read().replace('\n', '') data = fp.read().split("\n") @@ -100,7 +102,7 @@ class TestDeepPotAPBC(unittest.TestCase): @classmethod def setUpClass(cls): convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "deeppot.pbtxt")), "deeppot.pb" + str(infer_path / os.path.join("deeppot.pbtxt")), "deeppot.pb" ) cls.dp = DeepPot("deeppot.pb") @@ -278,7 +280,7 @@ def test_1frame_atm(self): def test_descriptor(self): descpt = self.dp.eval_descriptor(self.coords, self.box, self.atype) - expected_descpt = np.loadtxt(str(tests_path / "infer" / "deeppot_descpt.txt")) + expected_descpt = np.loadtxt(str(infer_path / "deeppot_descpt.txt")) np.testing.assert_almost_equal(descpt.ravel(), expected_descpt.ravel()) def test_2frame_atm(self): @@ -327,7 +329,7 @@ class TestDeepPotANoPBC(unittest.TestCase): @classmethod def setUpClass(cls): convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "deeppot.pbtxt")), "deeppot.pb" + str(infer_path / os.path.join("deeppot.pbtxt")), "deeppot.pb" ) cls.dp = DeepPot("deeppot.pb") @@ -550,7 +552,7 @@ class TestDeepPotALargeBoxNoPBC(unittest.TestCase): @classmethod def setUpClass(cls): convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "deeppot.pbtxt")), "deeppot.pb" + str(infer_path / os.path.join("deeppot.pbtxt")), "deeppot.pb" ) cls.dp = DeepPot("deeppot.pb") @@ -799,7 +801,7 @@ def setUp(self): def test_convert_012(self): old_model = "deeppot.pb" new_model = "deeppot-new.pb" - convert_pbtxt_to_pb(str(tests_path / "infer" / "sea_012.pbtxt"), old_model) + convert_pbtxt_to_pb(str(infer_path / "sea_012.pbtxt"), old_model) run_dp(f"dp convert-from 0.12 -i {old_model} -o {new_model}") dp = DeepPot(new_model) _, _, _, _, _ = dp.eval(self.coords, self.box, self.atype, atomic=True) @@ -809,7 +811,7 @@ def test_convert_012(self): def test_convert(self): old_model = "deeppot.pb" new_model = "deeppot-new.pb" - convert_pbtxt_to_pb(str(tests_path / "infer" / "sea_012.pbtxt"), old_model) + convert_pbtxt_to_pb(str(infer_path / "sea_012.pbtxt"), old_model) run_dp(f"dp convert-from -i {old_model} -o {new_model}") dp = DeepPot(new_model) _, _, _, _, _ = dp.eval(self.coords, self.box, self.atype, atomic=True) @@ -820,11 +822,11 @@ def test_detect(self): old_model = "deeppot.pb" new_model_txt = "deeppot_new.pbtxt" new_model_pb = "deeppot_new.pb" - convert_pbtxt_to_pb(str(tests_path / "infer" / "sea_012.pbtxt"), old_model) + convert_pbtxt_to_pb(str(infer_path / "sea_012.pbtxt"), old_model) version = detect_model_version(old_model) self.assertEqual(version, parse_version("0.12")) os.remove(old_model) - shutil.copyfile(str(tests_path / "infer" / "sea_012.pbtxt"), new_model_txt) + shutil.copyfile(str(infer_path / "sea_012.pbtxt"), new_model_txt) convert_dp012_to_dp10(new_model_txt) convert_pbtxt_to_pb(new_model_txt, new_model_pb) version = detect_model_version(new_model_pb) @@ -857,7 +859,7 @@ class TestTypeEmbed(unittest.TestCase): @classmethod def setUpClass(cls): convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "se_e2_a_tebd.pbtxt")), + str(infer_path / os.path.join("se_e2_a_tebd.pbtxt")), "se_e2_a_tebd.pb", ) cls.dp = DeepPot("se_e2_a_tebd.pb") @@ -898,7 +900,7 @@ class TestFparamAparam(unittest.TestCase): @classmethod def setUpClass(cls): convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "fparam_aparam.pbtxt")), + str(infer_path / os.path.join("fparam_aparam.pbtxt")), "fparam_aparam.pb", ) cls.dp = DeepPot("fparam_aparam.pb") @@ -1155,7 +1157,7 @@ class TestDeepPotAPBCNeighborList(TestDeepPotAPBC): @classmethod def setUpClass(cls): convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "deeppot.pbtxt")), "deeppot.pb" + str(infer_path / os.path.join("deeppot.pbtxt")), "deeppot.pb" ) cls.dp = DeepPot( "deeppot.pb", diff --git a/source/tests/test_deeppot_r.py b/source/tests/tf/test_deeppot_r.py similarity index 98% rename from source/tests/test_deeppot_r.py rename to source/tests/tf/test_deeppot_r.py index 47f957d2cd..482a8c42ee 100644 --- a/source/tests/test_deeppot_r.py +++ b/source/tests/tf/test_deeppot_r.py @@ -3,9 +3,6 @@ import unittest import numpy as np -from common import ( - tests_path, -) from deepmd.tf.env import ( GLOBAL_NP_FLOAT_PRECISION, @@ -18,6 +15,10 @@ convert_pbtxt_to_pb, ) +from .common import ( + infer_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: @@ -28,7 +29,7 @@ class TestDeepPotRPBC(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" ) cls.dp = DeepPot("deeppot.pb") @@ -239,7 +240,7 @@ class TestDeepPotRNoPBC(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" ) cls.dp = DeepPot("deeppot.pb") @@ -453,7 +454,7 @@ class TestDeepPotRLargeBoxNoPBC(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" ) cls.dp = DeepPot("deeppot.pb") diff --git a/source/tests/test_deeppot_spin.py b/source/tests/tf/test_deeppot_spin.py similarity index 98% rename from source/tests/test_deeppot_spin.py rename to source/tests/tf/test_deeppot_spin.py index b390fe6c79..d64cdf2dd6 100644 --- a/source/tests/test_deeppot_spin.py +++ b/source/tests/tf/test_deeppot_spin.py @@ -3,9 +3,6 @@ import unittest import numpy as np -from common import ( - tests_path, -) from deepmd.tf.env import ( GLOBAL_NP_FLOAT_PRECISION, @@ -17,6 +14,10 @@ convert_pbtxt_to_pb, ) +from .common import ( + infer_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: @@ -27,7 +28,7 @@ class TestDeepPotAPBC(unittest.TestCase): @classmethod def setUpClass(cls): convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "deepspin.pbtxt")), "deepspin.pb" + str(infer_path / os.path.join("deepspin.pbtxt")), "deepspin.pb" ) cls.dp = DeepPot("deepspin.pb") diff --git a/source/tests/test_descrpt_hybrid.py b/source/tests/tf/test_descrpt_hybrid.py similarity index 99% rename from source/tests/test_descrpt_hybrid.py rename to source/tests/tf/test_descrpt_hybrid.py index 08177f6a08..7c9d38cf7b 100644 --- a/source/tests/test_descrpt_hybrid.py +++ b/source/tests/tf/test_descrpt_hybrid.py @@ -2,11 +2,6 @@ import unittest import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from packaging.version import parse as parse_version from deepmd.tf.common import ( @@ -22,6 +17,12 @@ TypeEmbedNet, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_descrpt_nonsmth.py b/source/tests/tf/test_descrpt_nonsmth.py similarity index 99% rename from source/tests/test_descrpt_nonsmth.py rename to source/tests/tf/test_descrpt_nonsmth.py index 31f9da7ff2..63c5f15c85 100644 --- a/source/tests/test_descrpt_nonsmth.py +++ b/source/tests/tf/test_descrpt_nonsmth.py @@ -2,13 +2,6 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) # load grad of force module from deepmd.tf.env import ( @@ -18,6 +11,14 @@ tf, ) +from .common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) + class Inter: def setUp(self, data, comp=0, pbc=True, sess=None): diff --git a/source/tests/test_descrpt_se_a_mask.py b/source/tests/tf/test_descrpt_se_a_mask.py similarity index 94% rename from source/tests/test_descrpt_se_a_mask.py rename to source/tests/tf/test_descrpt_se_a_mask.py index b35bc75b04..b6488d88c6 100644 --- a/source/tests/test_descrpt_se_a_mask.py +++ b/source/tests/tf/test_descrpt_se_a_mask.py @@ -1,12 +1,7 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import os -import pathlib import numpy as np -from common import ( - DataSystem, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -24,21 +19,26 @@ convert_pbtxt_to_pb, ) +from .common import ( + DataSystem, + infer_path, + j_loader, + tests_path, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 -tests_path = pathlib.Path(__file__).parent.absolute() - class TestModel(tf.test.TestCase): @classmethod def setUpClass(cls): convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "dp4mask.pbtxt")), - str(tests_path / os.path.join("infer", "dp4mask.pb")), + str(infer_path / os.path.join("dp4mask.pbtxt")), + str(infer_path / os.path.join("dp4mask.pb")), ) - cls.dp = DeepPot(str(tests_path / os.path.join("infer", "dp4mask.pb"))) + cls.dp = DeepPot(str(infer_path / os.path.join("dp4mask.pb"))) def test_dp_mask_model(self): dcoord = np.array( @@ -225,6 +225,12 @@ def test_descriptor_se_a_mask(self): jfile = "zinc_se_a_mask.json" jdata = j_loader(jfile) + jdata["training"]["training_data"]["systems"] = [ + str(tests_path / "data_dp_mask") + ] + jdata["training"]["validation_data"]["systems"] = [ + str(tests_path / "data_dp_mask") + ] systems = j_must_have(jdata["training"]["validation_data"], "systems") # set_pfx = j_must_have(jdata['validation_data'], "set_prefix") set_pfx = "set" diff --git a/source/tests/test_descrpt_se_a_type.py b/source/tests/tf/test_descrpt_se_a_type.py similarity index 99% rename from source/tests/test_descrpt_se_a_type.py rename to source/tests/tf/test_descrpt_se_a_type.py index f5f294be35..43ed34dc92 100644 --- a/source/tests/test_descrpt_se_a_type.py +++ b/source/tests/tf/test_descrpt_se_a_type.py @@ -1,10 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -19,6 +14,12 @@ TypeEmbedNet, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_descrpt_se_atten.py b/source/tests/tf/test_descrpt_se_atten.py similarity index 99% rename from source/tests/test_descrpt_se_atten.py rename to source/tests/tf/test_descrpt_se_atten.py index d7e3c31f2c..d7ffc4bf8d 100644 --- a/source/tests/test_descrpt_se_atten.py +++ b/source/tests/tf/test_descrpt_se_atten.py @@ -3,11 +3,6 @@ import unittest import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from packaging.version import parse as parse_version from deepmd.tf.common import ( @@ -23,6 +18,12 @@ TypeEmbedNet, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_descrpt_se_r.py b/source/tests/tf/test_descrpt_se_r.py similarity index 99% rename from source/tests/test_descrpt_se_r.py rename to source/tests/tf/test_descrpt_se_r.py index 9e01bc83fd..d95c8fbb21 100644 --- a/source/tests/test_descrpt_se_r.py +++ b/source/tests/tf/test_descrpt_se_r.py @@ -2,13 +2,6 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) # load grad of force module from deepmd.tf.env import ( @@ -18,6 +11,14 @@ tf, ) +from .common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) + class Inter: def setUp(self, data, pbc=True, sess=None): diff --git a/source/tests/test_descrpt_sea_ef.py b/source/tests/tf/test_descrpt_sea_ef.py similarity index 99% rename from source/tests/test_descrpt_sea_ef.py rename to source/tests/tf/test_descrpt_sea_ef.py index 42f26da887..e9e990a659 100644 --- a/source/tests/test_descrpt_sea_ef.py +++ b/source/tests/tf/test_descrpt_sea_ef.py @@ -2,13 +2,6 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) # load grad of force module from deepmd.tf.env import ( @@ -18,6 +11,14 @@ tf, ) +from .common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) + class Inter: def setUp(self, data, pbc=True, sess=None): diff --git a/source/tests/test_descrpt_sea_ef_para.py b/source/tests/tf/test_descrpt_sea_ef_para.py similarity index 99% rename from source/tests/test_descrpt_sea_ef_para.py rename to source/tests/tf/test_descrpt_sea_ef_para.py index 16c92a5dc7..1af6ea648a 100644 --- a/source/tests/test_descrpt_sea_ef_para.py +++ b/source/tests/tf/test_descrpt_sea_ef_para.py @@ -2,13 +2,6 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) # load grad of force module from deepmd.tf.env import ( @@ -18,6 +11,14 @@ tf, ) +from .common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) + class Inter: def setUp(self, data, pbc=True, sess=None): diff --git a/source/tests/test_descrpt_sea_ef_rot.py b/source/tests/tf/test_descrpt_sea_ef_rot.py similarity index 100% rename from source/tests/test_descrpt_sea_ef_rot.py rename to source/tests/tf/test_descrpt_sea_ef_rot.py diff --git a/source/tests/test_descrpt_sea_ef_vert.py b/source/tests/tf/test_descrpt_sea_ef_vert.py similarity index 99% rename from source/tests/test_descrpt_sea_ef_vert.py rename to source/tests/tf/test_descrpt_sea_ef_vert.py index bc27a7c933..09bca9b754 100644 --- a/source/tests/test_descrpt_sea_ef_vert.py +++ b/source/tests/tf/test_descrpt_sea_ef_vert.py @@ -2,13 +2,6 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) # load grad of force module from deepmd.tf.env import ( @@ -18,6 +11,14 @@ tf, ) +from .common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) + class Inter: def setUp(self, data, pbc=True, sess=None): diff --git a/source/tests/test_descrpt_smooth.py b/source/tests/tf/test_descrpt_smooth.py similarity index 99% rename from source/tests/test_descrpt_smooth.py rename to source/tests/tf/test_descrpt_smooth.py index 206aca8d8a..91a3f7dbf0 100644 --- a/source/tests/test_descrpt_smooth.py +++ b/source/tests/tf/test_descrpt_smooth.py @@ -2,13 +2,6 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) # load grad of force module from deepmd.tf.env import ( @@ -18,6 +11,14 @@ tf, ) +from .common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) + class Inter: def setUp(self, data, pbc=True, sess=None): diff --git a/source/tests/test_dipole_se_a.py b/source/tests/tf/test_dipole_se_a.py similarity index 99% rename from source/tests/test_dipole_se_a.py rename to source/tests/tf/test_dipole_se_a.py index ca31ce87d5..f0e495ef21 100644 --- a/source/tests/test_dipole_se_a.py +++ b/source/tests/tf/test_dipole_se_a.py @@ -1,12 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - finite_difference, - gen_data, - j_loader, - strerch_box, -) from deepmd.tf.common import ( j_must_have, @@ -24,6 +17,14 @@ DipoleModel, ) +from .common import ( + DataSystem, + finite_difference, + gen_data, + j_loader, + strerch_box, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_dipole_se_a_tebd.py b/source/tests/tf/test_dipole_se_a_tebd.py similarity index 99% rename from source/tests/test_dipole_se_a_tebd.py rename to source/tests/tf/test_dipole_se_a_tebd.py index b211d0eb48..ed403bd047 100644 --- a/source/tests/test_dipole_se_a_tebd.py +++ b/source/tests/tf/test_dipole_se_a_tebd.py @@ -2,13 +2,6 @@ import unittest import numpy as np -from common import ( - DataSystem, - finite_difference, - gen_data, - j_loader, - strerch_box, -) from packaging.version import parse as parse_version from deepmd.tf.common import ( @@ -30,6 +23,14 @@ TypeEmbedNet, ) +from .common import ( + DataSystem, + finite_difference, + gen_data, + j_loader, + strerch_box, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_dipolecharge.py b/source/tests/tf/test_dipolecharge.py similarity index 98% rename from source/tests/test_dipolecharge.py rename to source/tests/tf/test_dipolecharge.py index e435eb431a..408b1bbdf2 100644 --- a/source/tests/test_dipolecharge.py +++ b/source/tests/tf/test_dipolecharge.py @@ -3,9 +3,6 @@ import unittest import numpy as np -from common import ( - tests_path, -) from deepmd.tf.env import ( GLOBAL_NP_FLOAT_PRECISION, @@ -17,6 +14,10 @@ convert_pbtxt_to_pb, ) +from .common import ( + infer_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: @@ -27,7 +28,7 @@ class TestDipoleCharge(unittest.TestCase): @classmethod def setUpClass(cls): convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "dipolecharge_d.pbtxt")), + str(infer_path / os.path.join("dipolecharge_d.pbtxt")), "dipolecharge_d.pb", ) cls.dp = DipoleChargeModifier( diff --git a/source/tests/test_dp_test.py b/source/tests/tf/test_dp_test.py similarity index 97% rename from source/tests/test_dp_test.py rename to source/tests/tf/test_dp_test.py index 978cd95804..9a3dde3da0 100644 --- a/source/tests/test_dp_test.py +++ b/source/tests/tf/test_dp_test.py @@ -8,15 +8,16 @@ import dpdata import numpy as np -from common import ( - tests_path, -) from deepmd.tf.entrypoints.test import test as dp_test from deepmd.tf.utils.convert import ( convert_pbtxt_to_pb, ) +from .common import ( + infer_path, +) + default_places = 6 @@ -71,7 +72,7 @@ class TestDPTestEner(unittest.TestCase, TestDPTest): def setUpClass(cls): cls.model_name = "deeppot.pb" convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "deeppot.pbtxt")), cls.model_name + str(infer_path / os.path.join("deeppot.pbtxt")), cls.model_name ) def setUp(self): @@ -207,7 +208,7 @@ class TestDPTestDipole(unittest.TestCase, TestDPTest): def setUpClass(cls): cls.model_name = "deepdipole.pb" convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "deepdipole.pbtxt")), cls.model_name + str(infer_path / os.path.join("deepdipole.pbtxt")), cls.model_name ) def setUp(self): @@ -266,7 +267,7 @@ class TestDPTestPolar(unittest.TestCase, TestDPTest): def setUpClass(cls): cls.model_name = "deeppolar.pb" convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "deeppolar.pbtxt")), cls.model_name + str(infer_path / os.path.join("deeppolar.pbtxt")), cls.model_name ) def setUp(self): diff --git a/source/tests/test_embedding_net.py b/source/tests/tf/test_embedding_net.py similarity index 100% rename from source/tests/test_embedding_net.py rename to source/tests/tf/test_embedding_net.py diff --git a/source/tests/test_env.py b/source/tests/tf/test_env.py similarity index 100% rename from source/tests/test_env.py rename to source/tests/tf/test_env.py diff --git a/source/tests/test_ewald.py b/source/tests/tf/test_ewald.py similarity index 100% rename from source/tests/test_ewald.py rename to source/tests/tf/test_ewald.py diff --git a/source/tests/test_finetune_se_atten.py b/source/tests/tf/test_finetune_se_atten.py similarity index 99% rename from source/tests/test_finetune_se_atten.py rename to source/tests/tf/test_finetune_se_atten.py index 47fedcf685..35eb994a46 100644 --- a/source/tests/test_finetune_se_atten.py +++ b/source/tests/tf/test_finetune_se_atten.py @@ -5,11 +5,6 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) from packaging.version import parse as parse_version from deepmd.tf.env import ( @@ -32,6 +27,12 @@ get_tensor_by_name, ) +from .common import ( + j_loader, + run_dp, + tests_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: diff --git a/source/tests/test_fitting_dos.py b/source/tests/tf/test_fitting_dos.py similarity index 99% rename from source/tests/test_fitting_dos.py rename to source/tests/tf/test_fitting_dos.py index 532bcfafbc..a2a54d6287 100644 --- a/source/tests/test_fitting_dos.py +++ b/source/tests/tf/test_fitting_dos.py @@ -1,10 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -19,6 +14,12 @@ DOSFitting, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_fitting_ener_type.py b/source/tests/tf/test_fitting_ener_type.py similarity index 99% rename from source/tests/test_fitting_ener_type.py rename to source/tests/tf/test_fitting_ener_type.py index 05a9d053ab..4dd6fb80a1 100644 --- a/source/tests/test_fitting_ener_type.py +++ b/source/tests/tf/test_fitting_ener_type.py @@ -1,10 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -19,6 +14,12 @@ EnerFitting, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_fitting_stat.py b/source/tests/tf/test_fitting_stat.py similarity index 99% rename from source/tests/test_fitting_stat.py rename to source/tests/tf/test_fitting_stat.py index 2b20dd5a4c..9e2408c57b 100644 --- a/source/tests/test_fitting_stat.py +++ b/source/tests/tf/test_fitting_stat.py @@ -5,9 +5,6 @@ ) import numpy as np -from common import ( - j_loader, -) from deepmd.tf.descriptor import ( DescrptSeA, @@ -16,6 +13,10 @@ EnerFitting, ) +from .common import ( + j_loader, +) + input_json = "water_se_a_afparam.json" diff --git a/source/tests/test_gen_stat_data.py b/source/tests/tf/test_gen_stat_data.py similarity index 100% rename from source/tests/test_gen_stat_data.py rename to source/tests/tf/test_gen_stat_data.py diff --git a/source/tests/test_get_potential.py b/source/tests/tf/test_get_potential.py similarity index 96% rename from source/tests/test_get_potential.py rename to source/tests/tf/test_get_potential.py index feb264afe0..47462a20a3 100644 --- a/source/tests/test_get_potential.py +++ b/source/tests/tf/test_get_potential.py @@ -2,9 +2,6 @@ """Test if `DeepPotential` facto function returns the right type of potential.""" import unittest -from pathlib import ( - Path, -) from deepmd.tf.infer import ( DeepDipole, @@ -16,10 +13,14 @@ convert_pbtxt_to_pb, ) +from .common import ( + infer_path, +) + class TestGetPotential(unittest.TestCase): def setUp(self): - self.work_dir = Path(__file__).parent / "infer" + self.work_dir = infer_path convert_pbtxt_to_pb( str(self.work_dir / "deeppot.pbtxt"), str(self.work_dir / "deep_pot.pb") diff --git a/source/tests/test_init_frz_model_multi.py b/source/tests/tf/test_init_frz_model_multi.py similarity index 99% rename from source/tests/test_init_frz_model_multi.py rename to source/tests/tf/test_init_frz_model_multi.py index fc37d82397..b723134ca1 100644 --- a/source/tests/test_init_frz_model_multi.py +++ b/source/tests/tf/test_init_frz_model_multi.py @@ -4,11 +4,6 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) from deepmd.tf.env import ( GLOBAL_NP_FLOAT_PRECISION, @@ -33,6 +28,12 @@ replace_model_params_with_frz_multi_model, ) +from .common import ( + j_loader, + run_dp, + tests_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: diff --git a/source/tests/test_init_frz_model_se_a.py b/source/tests/tf/test_init_frz_model_se_a.py similarity index 99% rename from source/tests/test_init_frz_model_se_a.py rename to source/tests/tf/test_init_frz_model_se_a.py index 7545e3aae9..5d4ed1063c 100644 --- a/source/tests/test_init_frz_model_se_a.py +++ b/source/tests/tf/test_init_frz_model_se_a.py @@ -4,11 +4,6 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) from deepmd.tf.env import ( GLOBAL_NP_FLOAT_PRECISION, @@ -30,6 +25,12 @@ DeepmdDataSystem, ) +from .common import ( + j_loader, + run_dp, + tests_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: diff --git a/source/tests/test_init_frz_model_se_a_tebd.py b/source/tests/tf/test_init_frz_model_se_a_tebd.py similarity index 99% rename from source/tests/test_init_frz_model_se_a_tebd.py rename to source/tests/tf/test_init_frz_model_se_a_tebd.py index 1b282c00d5..afc1e46ed8 100644 --- a/source/tests/test_init_frz_model_se_a_tebd.py +++ b/source/tests/tf/test_init_frz_model_se_a_tebd.py @@ -4,11 +4,6 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) from deepmd.tf.env import ( GLOBAL_NP_FLOAT_PRECISION, @@ -30,6 +25,12 @@ DeepmdDataSystem, ) +from .common import ( + j_loader, + run_dp, + tests_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: diff --git a/source/tests/test_init_frz_model_se_a_type.py b/source/tests/tf/test_init_frz_model_se_a_type.py similarity index 99% rename from source/tests/test_init_frz_model_se_a_type.py rename to source/tests/tf/test_init_frz_model_se_a_type.py index b356dbf6d0..48ff4eb294 100644 --- a/source/tests/test_init_frz_model_se_a_type.py +++ b/source/tests/tf/test_init_frz_model_se_a_type.py @@ -4,11 +4,6 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) from deepmd.tf.env import ( GLOBAL_NP_FLOAT_PRECISION, @@ -30,6 +25,12 @@ DeepmdDataSystem, ) +from .common import ( + j_loader, + run_dp, + tests_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: diff --git a/source/tests/test_init_frz_model_se_atten.py b/source/tests/tf/test_init_frz_model_se_atten.py similarity index 99% rename from source/tests/test_init_frz_model_se_atten.py rename to source/tests/tf/test_init_frz_model_se_atten.py index 7889440cd3..a114deffc8 100644 --- a/source/tests/test_init_frz_model_se_atten.py +++ b/source/tests/tf/test_init_frz_model_se_atten.py @@ -4,11 +4,6 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) from packaging.version import parse as parse_version from deepmd.tf.env import ( @@ -31,6 +26,12 @@ DeepmdDataSystem, ) +from .common import ( + j_loader, + run_dp, + tests_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: diff --git a/source/tests/test_init_frz_model_se_r.py b/source/tests/tf/test_init_frz_model_se_r.py similarity index 99% rename from source/tests/test_init_frz_model_se_r.py rename to source/tests/tf/test_init_frz_model_se_r.py index fd916b3fdc..100c09196e 100644 --- a/source/tests/test_init_frz_model_se_r.py +++ b/source/tests/tf/test_init_frz_model_se_r.py @@ -4,11 +4,6 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) from deepmd.tf.env import ( GLOBAL_NP_FLOAT_PRECISION, @@ -30,6 +25,12 @@ DeepmdDataSystem, ) +from .common import ( + j_loader, + run_dp, + tests_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: diff --git a/source/tests/test_init_frz_model_spin.py b/source/tests/tf/test_init_frz_model_spin.py similarity index 99% rename from source/tests/test_init_frz_model_spin.py rename to source/tests/tf/test_init_frz_model_spin.py index b5c480c2ba..c2c433cde0 100644 --- a/source/tests/test_init_frz_model_spin.py +++ b/source/tests/tf/test_init_frz_model_spin.py @@ -4,11 +4,6 @@ import unittest import numpy as np -from common import ( - j_loader, - run_dp, - tests_path, -) from deepmd.tf.env import ( GLOBAL_NP_FLOAT_PRECISION, @@ -30,6 +25,12 @@ DeepmdDataSystem, ) +from .common import ( + j_loader, + run_dp, + tests_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: diff --git a/source/tests/test_lammps.py b/source/tests/tf/test_lammps.py similarity index 87% rename from source/tests/test_lammps.py rename to source/tests/tf/test_lammps.py index d235d6576e..b295d5212a 100644 --- a/source/tests/test_lammps.py +++ b/source/tests/tf/test_lammps.py @@ -2,14 +2,15 @@ import os import subprocess import unittest -from pathlib import ( - Path, -) from deepmd.tf.utils.convert import ( convert_pbtxt_to_pb, ) +from .common import ( + infer_path, +) + @unittest.skipIf( os.environ.get("CIBUILDWHEEL", "0") != "1", @@ -20,7 +21,7 @@ class TestLAMMPS(unittest.TestCase): @classmethod def setUpClass(cls): - cls.work_dir = (Path(__file__).parent / "infer").absolute() + cls.work_dir = infer_path convert_pbtxt_to_pb( str(cls.work_dir / "deeppot.pbtxt"), str(cls.work_dir / "deep_pot.pb") diff --git a/source/tests/test_layer_name.py b/source/tests/tf/test_layer_name.py similarity index 99% rename from source/tests/test_layer_name.py rename to source/tests/tf/test_layer_name.py index 71229b5ce7..8c2264315f 100644 --- a/source/tests/test_layer_name.py +++ b/source/tests/tf/test_layer_name.py @@ -1,11 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - del_data, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -24,6 +18,13 @@ MultiModel, ) +from .common import ( + DataSystem, + del_data, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_linear_model.py b/source/tests/tf/test_linear_model.py similarity index 94% rename from source/tests/test_linear_model.py rename to source/tests/tf/test_linear_model.py index ef0d324a69..95ece9c19f 100644 --- a/source/tests/test_linear_model.py +++ b/source/tests/tf/test_linear_model.py @@ -1,6 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import os -import sys import numpy as np @@ -19,12 +18,11 @@ convert_pbtxt_to_pb, ) -sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) -from common import ( +from .common import ( DataSystem, del_data, gen_data, - tests_path, + infer_path, ) @@ -35,8 +33,8 @@ def setUp(self): with open(os.path.join(self.data_dir, "type_map.raw"), "w") as f: f.write("O\nH") self.pbtxts = [ - os.path.join(tests_path, "infer/deeppot.pbtxt"), - os.path.join(tests_path, "infer/deeppot-1.pbtxt"), + os.path.join(infer_path, "deeppot.pbtxt"), + os.path.join(infer_path, "deeppot-1.pbtxt"), ] self.graph_dirs = [pbtxt.replace("pbtxt", "pb") for pbtxt in self.pbtxts] for pbtxt, pb in zip(self.pbtxts, self.graph_dirs): diff --git a/source/tests/test_loss_gf.py b/source/tests/tf/test_loss_gf.py similarity index 100% rename from source/tests/test_loss_gf.py rename to source/tests/tf/test_loss_gf.py diff --git a/source/tests/test_mixed_prec_training.py b/source/tests/tf/test_mixed_prec_training.py similarity index 99% rename from source/tests/test_mixed_prec_training.py rename to source/tests/tf/test_mixed_prec_training.py index 620a9b9fd0..63504134af 100644 --- a/source/tests/test_mixed_prec_training.py +++ b/source/tests/tf/test_mixed_prec_training.py @@ -5,13 +5,6 @@ import unittest import numpy as np - -# from deepmd.tf.entrypoints.compress import compress -from common import ( - j_loader, - run_dp, - tests_path, -) from packaging.version import ( Version, ) @@ -20,6 +13,13 @@ TF_VERSION, ) +# from deepmd.tf.entrypoints.compress import compress +from .common import ( + j_loader, + run_dp, + tests_path, +) + def _file_delete(file): if os.path.isdir(file): diff --git a/source/tests/test_model_compression_se_a.py b/source/tests/tf/test_model_compression_se_a.py similarity index 99% rename from source/tests/test_model_compression_se_a.py rename to source/tests/tf/test_model_compression_se_a.py index 0a6b7c85cb..37d1857661 100644 --- a/source/tests/test_model_compression_se_a.py +++ b/source/tests/tf/test_model_compression_se_a.py @@ -6,13 +6,6 @@ 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, ) @@ -20,6 +13,13 @@ 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: diff --git a/source/tests/test_model_compression_se_a_ebd.py b/source/tests/tf/test_model_compression_se_a_ebd.py similarity index 99% rename from source/tests/test_model_compression_se_a_ebd.py rename to source/tests/tf/test_model_compression_se_a_ebd.py index 8b64117acd..1ab0cfe5cc 100644 --- a/source/tests/test_model_compression_se_a_ebd.py +++ b/source/tests/tf/test_model_compression_se_a_ebd.py @@ -6,13 +6,6 @@ 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, ) @@ -20,6 +13,13 @@ 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: diff --git a/source/tests/test_model_compression_se_a_ebd_type_one_side.py b/source/tests/tf/test_model_compression_se_a_ebd_type_one_side.py similarity index 99% rename from source/tests/test_model_compression_se_a_ebd_type_one_side.py rename to source/tests/tf/test_model_compression_se_a_ebd_type_one_side.py index 741c95b26e..5ae8ef4990 100644 --- a/source/tests/test_model_compression_se_a_ebd_type_one_side.py +++ b/source/tests/tf/test_model_compression_se_a_ebd_type_one_side.py @@ -6,13 +6,6 @@ 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, ) @@ -20,6 +13,13 @@ 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: diff --git a/source/tests/test_model_compression_se_a_type_one_side_exclude_types.py b/source/tests/tf/test_model_compression_se_a_type_one_side_exclude_types.py similarity index 99% rename from source/tests/test_model_compression_se_a_type_one_side_exclude_types.py rename to source/tests/tf/test_model_compression_se_a_type_one_side_exclude_types.py index bdf09cf3e8..3726fc2bda 100644 --- a/source/tests/test_model_compression_se_a_type_one_side_exclude_types.py +++ b/source/tests/tf/test_model_compression_se_a_type_one_side_exclude_types.py @@ -6,13 +6,6 @@ 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, ) @@ -20,6 +13,13 @@ 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: diff --git a/source/tests/test_model_compression_se_atten.py b/source/tests/tf/test_model_compression_se_atten.py similarity index 99% rename from source/tests/test_model_compression_se_atten.py rename to source/tests/tf/test_model_compression_se_atten.py index 2e250fe80e..dbc54dd51a 100644 --- a/source/tests/test_model_compression_se_atten.py +++ b/source/tests/tf/test_model_compression_se_atten.py @@ -5,13 +5,6 @@ import unittest import numpy as np - -# 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 ( @@ -21,6 +14,13 @@ DeepPot, ) +# from deepmd.tf.entrypoints.compress import compress +from .common import ( + j_loader, + run_dp, + tests_path, +) + def _file_delete(file): if os.path.isdir(file): diff --git a/source/tests/test_model_compression_se_r.py b/source/tests/tf/test_model_compression_se_r.py similarity index 99% rename from source/tests/test_model_compression_se_r.py rename to source/tests/tf/test_model_compression_se_r.py index 0c5912164f..4a5d9ad9f6 100644 --- a/source/tests/test_model_compression_se_r.py +++ b/source/tests/tf/test_model_compression_se_r.py @@ -6,13 +6,6 @@ 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, ) @@ -20,6 +13,13 @@ 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: diff --git a/source/tests/test_model_compression_se_t.py b/source/tests/tf/test_model_compression_se_t.py similarity index 99% rename from source/tests/test_model_compression_se_t.py rename to source/tests/tf/test_model_compression_se_t.py index eb33ce2b93..0cf1135f8a 100644 --- a/source/tests/test_model_compression_se_t.py +++ b/source/tests/tf/test_model_compression_se_t.py @@ -6,13 +6,6 @@ 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, ) @@ -20,6 +13,13 @@ 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: diff --git a/source/tests/test_model_devi.py b/source/tests/tf/test_model_devi.py similarity index 97% rename from source/tests/test_model_devi.py rename to source/tests/tf/test_model_devi.py index 21275ee2d1..58a6266ca9 100644 --- a/source/tests/test_model_devi.py +++ b/source/tests/tf/test_model_devi.py @@ -1,6 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import os -import sys import unittest import numpy as np @@ -12,18 +11,17 @@ from deepmd.tf.infer.model_devi import ( make_model_devi, ) +from deepmd.tf.utils.convert import ( + convert_pbtxt_to_pb, +) -sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) -from common import ( +from .common import ( del_data, gen_data, + infer_path, tests_path, ) -from deepmd.tf.utils.convert import ( - convert_pbtxt_to_pb, -) - class TestMakeModelDevi(unittest.TestCase): def setUp(self): @@ -39,8 +37,8 @@ def setUp(self): self.freq = 10 self.pbtxts = [ - os.path.join(tests_path, "infer/deeppot.pbtxt"), - os.path.join(tests_path, "infer/deeppot-1.pbtxt"), + os.path.join(infer_path, "deeppot.pbtxt"), + os.path.join(infer_path, "deeppot-1.pbtxt"), ] self.graph_dirs = [pbtxt.replace("pbtxt", "pb") for pbtxt in self.pbtxts] for pbtxt, pb in zip(self.pbtxts, self.graph_dirs): @@ -215,7 +213,7 @@ class TestMakeModelDeviFparamAparam(unittest.TestCase): @classmethod def setUpClass(cls): cls.pbtxts = [ - os.path.join(tests_path, "infer/fparam_aparam.pbtxt"), + os.path.join(infer_path, "fparam_aparam.pbtxt"), ] cls.graph_dirs = [pbtxt.replace("pbtxt", "pb") for pbtxt in cls.pbtxts] for pbtxt, pb in zip(cls.pbtxts, cls.graph_dirs): diff --git a/source/tests/test_model_devi_mix.py b/source/tests/tf/test_model_devi_mix.py similarity index 94% rename from source/tests/test_model_devi_mix.py rename to source/tests/tf/test_model_devi_mix.py index 5715b49165..d9062e939a 100644 --- a/source/tests/test_model_devi_mix.py +++ b/source/tests/tf/test_model_devi_mix.py @@ -1,10 +1,13 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import os -import sys import unittest import numpy as np +from packaging.version import parse as parse_version +from deepmd.tf.env import ( + tf, +) from deepmd.tf.infer import ( DeepPotential, calc_model_devi, @@ -12,21 +15,16 @@ from deepmd.tf.infer.model_devi import ( make_model_devi, ) +from deepmd.tf.utils.convert import ( + convert_pbtxt_to_pb, +) -sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) -from common import ( +from .common import ( del_data, gen_data, + infer_path, tests_path, ) -from packaging.version import parse as parse_version - -from deepmd.tf.env import ( - tf, -) -from deepmd.tf.utils.convert import ( - convert_pbtxt_to_pb, -) @unittest.skipIf( @@ -56,8 +54,8 @@ def setUp(self): ) self.pbtxts = [ - os.path.join(tests_path, "infer/se_atten_no_atten_1.pbtxt"), - os.path.join(tests_path, "infer/se_atten_no_atten_2.pbtxt"), + os.path.join(infer_path, "se_atten_no_atten_1.pbtxt"), + os.path.join(infer_path, "se_atten_no_atten_2.pbtxt"), ] self.graph_dirs = [pbtxt.replace("pbtxt", "pb") for pbtxt in self.pbtxts] for pbtxt, pb in zip(self.pbtxts, self.graph_dirs): diff --git a/source/tests/test_model_dos.py b/source/tests/tf/test_model_dos.py similarity index 99% rename from source/tests/test_model_dos.py rename to source/tests/tf/test_model_dos.py index 72cd9db524..d88c81c332 100644 --- a/source/tests/test_model_dos.py +++ b/source/tests/tf/test_model_dos.py @@ -1,11 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - del_data, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -23,6 +17,13 @@ DOSModel, ) +from .common import ( + DataSystem, + del_data, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_loc_frame.py b/source/tests/tf/test_model_loc_frame.py similarity index 99% rename from source/tests/test_model_loc_frame.py rename to source/tests/tf/test_model_loc_frame.py index 035ffc868e..f97e349145 100644 --- a/source/tests/test_model_loc_frame.py +++ b/source/tests/tf/test_model_loc_frame.py @@ -1,10 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -22,6 +17,12 @@ EnerModel, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_multi.py b/source/tests/tf/test_model_multi.py similarity index 99% rename from source/tests/test_model_multi.py rename to source/tests/tf/test_model_multi.py index fa75951366..c526b479a6 100644 --- a/source/tests/test_model_multi.py +++ b/source/tests/tf/test_model_multi.py @@ -1,13 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - del_data, - finite_difference, - gen_data, - j_loader, - strerch_box, -) from deepmd.tf.common import ( j_must_have, @@ -26,6 +18,15 @@ MultiModel, ) +from .common import ( + DataSystem, + del_data, + finite_difference, + gen_data, + j_loader, + strerch_box, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_pairtab.py b/source/tests/tf/test_model_pairtab.py similarity index 99% rename from source/tests/test_model_pairtab.py rename to source/tests/tf/test_model_pairtab.py index 8a7ebd605c..e2c45ee50c 100644 --- a/source/tests/test_model_pairtab.py +++ b/source/tests/tf/test_model_pairtab.py @@ -1,11 +1,6 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np import scipy.spatial.distance -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -17,6 +12,12 @@ Model, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_se_a.py b/source/tests/tf/test_model_se_a.py similarity index 99% rename from source/tests/test_model_se_a.py rename to source/tests/tf/test_model_se_a.py index f537452385..57a8f4af52 100644 --- a/source/tests/test_model_se_a.py +++ b/source/tests/tf/test_model_se_a.py @@ -1,12 +1,6 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import dpdata import numpy as np -from common import ( - DataSystem, - del_data, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -27,6 +21,13 @@ TypeEmbedNet, ) +from .common import ( + DataSystem, + del_data, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_se_a_aparam.py b/source/tests/tf/test_model_se_a_aparam.py similarity index 99% rename from source/tests/test_model_se_a_aparam.py rename to source/tests/tf/test_model_se_a_aparam.py index aca2d8c63c..6b37dfd459 100644 --- a/source/tests/test_model_se_a_aparam.py +++ b/source/tests/tf/test_model_se_a_aparam.py @@ -1,10 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -22,6 +17,12 @@ EnerModel, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_se_a_ebd.py b/source/tests/tf/test_model_se_a_ebd.py similarity index 99% rename from source/tests/test_model_se_a_ebd.py rename to source/tests/tf/test_model_se_a_ebd.py index 2e133a9a63..b819c2ddc9 100644 --- a/source/tests/test_model_se_a_ebd.py +++ b/source/tests/tf/test_model_se_a_ebd.py @@ -1,10 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -22,6 +17,12 @@ EnerModel, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_se_a_ebd_v2.py b/source/tests/tf/test_model_se_a_ebd_v2.py similarity index 99% rename from source/tests/test_model_se_a_ebd_v2.py rename to source/tests/tf/test_model_se_a_ebd_v2.py index f302308a73..0cc89f5151 100644 --- a/source/tests/test_model_se_a_ebd_v2.py +++ b/source/tests/tf/test_model_se_a_ebd_v2.py @@ -1,10 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -25,6 +20,12 @@ TypeEmbedNet, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_se_a_fparam.py b/source/tests/tf/test_model_se_a_fparam.py similarity index 99% rename from source/tests/test_model_se_a_fparam.py rename to source/tests/tf/test_model_se_a_fparam.py index 46aac18fcb..806ae13582 100644 --- a/source/tests/test_model_se_a_fparam.py +++ b/source/tests/tf/test_model_se_a_fparam.py @@ -1,10 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -22,6 +17,12 @@ EnerModel, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_se_a_srtab.py b/source/tests/tf/test_model_se_a_srtab.py similarity index 99% rename from source/tests/test_model_se_a_srtab.py rename to source/tests/tf/test_model_se_a_srtab.py index 3fcb55050d..3a93349741 100644 --- a/source/tests/test_model_se_a_srtab.py +++ b/source/tests/tf/test_model_se_a_srtab.py @@ -2,11 +2,6 @@ import os import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -24,6 +19,12 @@ EnerModel, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_se_a_type.py b/source/tests/tf/test_model_se_a_type.py similarity index 99% rename from source/tests/test_model_se_a_type.py rename to source/tests/tf/test_model_se_a_type.py index bc2a2c3045..4b19378cf6 100644 --- a/source/tests/test_model_se_a_type.py +++ b/source/tests/tf/test_model_se_a_type.py @@ -1,10 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -25,6 +20,12 @@ TypeEmbedNet, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_se_atten.py b/source/tests/tf/test_model_se_atten.py similarity index 99% rename from source/tests/test_model_se_atten.py rename to source/tests/tf/test_model_se_atten.py index 592858db2a..ad6926e0da 100644 --- a/source/tests/test_model_se_atten.py +++ b/source/tests/tf/test_model_se_atten.py @@ -3,13 +3,6 @@ import unittest import numpy as np -from common import ( - DataSystem, - check_smooth_efv, - finite_difference_fv, - gen_data, - j_loader, -) from packaging.version import parse as parse_version from deepmd.tf.common import ( @@ -31,6 +24,14 @@ TypeEmbedNet, ) +from .common import ( + DataSystem, + check_smooth_efv, + finite_difference_fv, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_se_r.py b/source/tests/tf/test_model_se_r.py similarity index 99% rename from source/tests/test_model_se_r.py rename to source/tests/tf/test_model_se_r.py index acfe6e95dd..a635e6c3c4 100644 --- a/source/tests/test_model_se_r.py +++ b/source/tests/tf/test_model_se_r.py @@ -1,10 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -22,6 +17,12 @@ EnerModel, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_se_t.py b/source/tests/tf/test_model_se_t.py similarity index 99% rename from source/tests/test_model_se_t.py rename to source/tests/tf/test_model_se_t.py index cb8ed97833..881a0e06c4 100644 --- a/source/tests/test_model_se_t.py +++ b/source/tests/tf/test_model_se_t.py @@ -1,10 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -22,6 +17,12 @@ EnerModel, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_model_spin.json b/source/tests/tf/test_model_spin.json similarity index 100% rename from source/tests/test_model_spin.json rename to source/tests/tf/test_model_spin.json diff --git a/source/tests/test_model_spin.py b/source/tests/tf/test_model_spin.py similarity index 99% rename from source/tests/test_model_spin.py rename to source/tests/tf/test_model_spin.py index d1a6f59fe1..26100c19d0 100644 --- a/source/tests/test_model_spin.py +++ b/source/tests/tf/test_model_spin.py @@ -2,13 +2,6 @@ import unittest import numpy as np -from common import ( - DataSystem, - del_data, - gen_data, - j_loader, - tests_path, -) from deepmd.tf.common import ( j_must_have, @@ -29,6 +22,14 @@ Spin, ) +from .common import ( + DataSystem, + del_data, + gen_data, + j_loader, + tests_path, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 @@ -46,7 +47,6 @@ def test_model_spin(self): jdata = j_loader(jfile) # set system information - systems = j_must_have(jdata["training"]["training_data"], "systems") set_pfx = j_must_have(jdata["training"], "set_prefix") batch_size = j_must_have(jdata["training"]["training_data"], "batch_size") batch_size = 2 @@ -59,6 +59,7 @@ def test_model_spin(self): jdata["training"]["validation_data"]["systems"] = [ str(tests_path / "model_spin/") ] + systems = j_must_have(jdata["training"]["training_data"], "systems") data = DataSystem(systems, set_pfx, batch_size, test_size, rcut, run_opt=None) test_data = data.get_test() diff --git a/source/tests/test_neighbor_stat.py b/source/tests/tf/test_neighbor_stat.py similarity index 100% rename from source/tests/test_neighbor_stat.py rename to source/tests/tf/test_neighbor_stat.py diff --git a/source/tests/test_nvnmd_entrypoints.py b/source/tests/tf/test_nvnmd_entrypoints.py similarity index 99% rename from source/tests/test_nvnmd_entrypoints.py rename to source/tests/tf/test_nvnmd_entrypoints.py index b257f8fffa..cc7a92c032 100644 --- a/source/tests/test_nvnmd_entrypoints.py +++ b/source/tests/tf/test_nvnmd_entrypoints.py @@ -3,9 +3,6 @@ import numpy as np import pytest -from common import ( - tests_path, -) from deepmd.tf.env import ( GLOBAL_TF_FLOAT_PRECISION, @@ -44,6 +41,10 @@ update_deepmd_input, ) +from .common import ( + tests_path, +) + class TestNvnmdEntrypointsV0(tf.test.TestCase): @pytest.mark.run(order=0) diff --git a/source/tests/test_nvnmd_op.py b/source/tests/tf/test_nvnmd_op.py similarity index 100% rename from source/tests/test_nvnmd_op.py rename to source/tests/tf/test_nvnmd_op.py diff --git a/source/tests/test_pairwise_dprc.py b/source/tests/tf/test_pairwise_dprc.py similarity index 99% rename from source/tests/test_pairwise_dprc.py rename to source/tests/tf/test_pairwise_dprc.py index a38c856c26..afe6885542 100644 --- a/source/tests/test_pairwise_dprc.py +++ b/source/tests/tf/test_pairwise_dprc.py @@ -5,10 +5,6 @@ import dpdata import numpy as np -from common import ( - run_dp, - tests_path, -) from packaging.version import parse as parse_version from deepmd.tf import ( @@ -38,6 +34,11 @@ run_sess, ) +from .common import ( + run_dp, + tests_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: diff --git a/source/tests/test_parallel_training.py b/source/tests/tf/test_parallel_training.py similarity index 98% rename from source/tests/test_parallel_training.py rename to source/tests/tf/test_parallel_training.py index 85311cf558..1f93c809a2 100644 --- a/source/tests/test_parallel_training.py +++ b/source/tests/tf/test_parallel_training.py @@ -3,14 +3,14 @@ import subprocess as sp import unittest -from common import ( - tests_path, -) - from deepmd.tf.cluster.local import ( get_gpus, ) +from .common import ( + tests_path, +) + class TestSingleMachine(unittest.TestCase): def setUp(self): diff --git a/source/tests/test_polar_se_a.py b/source/tests/tf/test_polar_se_a.py similarity index 99% rename from source/tests/test_polar_se_a.py rename to source/tests/tf/test_polar_se_a.py index 39c34f0a01..04487dec7b 100644 --- a/source/tests/test_polar_se_a.py +++ b/source/tests/tf/test_polar_se_a.py @@ -1,12 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - finite_difference, - gen_data, - j_loader, - strerch_box, -) from deepmd.tf.common import ( j_must_have, @@ -24,6 +17,14 @@ PolarModel, ) +from .common import ( + DataSystem, + finite_difference, + gen_data, + j_loader, + strerch_box, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_polar_se_a_tebd.py b/source/tests/tf/test_polar_se_a_tebd.py similarity index 99% rename from source/tests/test_polar_se_a_tebd.py rename to source/tests/tf/test_polar_se_a_tebd.py index 1c82488dca..38c3ae20ef 100644 --- a/source/tests/test_polar_se_a_tebd.py +++ b/source/tests/tf/test_polar_se_a_tebd.py @@ -2,13 +2,6 @@ import unittest import numpy as np -from common import ( - DataSystem, - finite_difference, - gen_data, - j_loader, - strerch_box, -) from packaging.version import parse as parse_version from deepmd.tf.common import ( @@ -30,6 +23,14 @@ TypeEmbedNet, ) +from .common import ( + DataSystem, + finite_difference, + gen_data, + j_loader, + strerch_box, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_prod_env_mat.py b/source/tests/tf/test_prod_env_mat.py similarity index 100% rename from source/tests/test_prod_env_mat.py rename to source/tests/tf/test_prod_env_mat.py diff --git a/source/tests/test_prod_force.py b/source/tests/tf/test_prod_force.py similarity index 100% rename from source/tests/test_prod_force.py rename to source/tests/tf/test_prod_force.py diff --git a/source/tests/test_prod_force_grad.py b/source/tests/tf/test_prod_force_grad.py similarity index 100% rename from source/tests/test_prod_force_grad.py rename to source/tests/tf/test_prod_force_grad.py diff --git a/source/tests/test_prod_virial.py b/source/tests/tf/test_prod_virial.py similarity index 100% rename from source/tests/test_prod_virial.py rename to source/tests/tf/test_prod_virial.py diff --git a/source/tests/test_prod_virial_grad.py b/source/tests/tf/test_prod_virial_grad.py similarity index 100% rename from source/tests/test_prod_virial_grad.py rename to source/tests/tf/test_prod_virial_grad.py diff --git a/source/tests/test_tab_nonsmth.py b/source/tests/tf/test_tab_nonsmth.py similarity index 98% rename from source/tests/test_tab_nonsmth.py rename to source/tests/tf/test_tab_nonsmth.py index 6b09b98428..7132d0c206 100644 --- a/source/tests/test_tab_nonsmth.py +++ b/source/tests/tf/test_tab_nonsmth.py @@ -3,16 +3,6 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) -from test_descrpt_nonsmth import ( - Inter, -) # load grad of force module import deepmd.tf.op # noqa: F401 @@ -24,6 +14,17 @@ PairTab, ) +from .common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) +from .test_descrpt_nonsmth import ( + Inter, +) + def _make_tab(ntype): xx = np.arange(0, 9, 0.001) diff --git a/source/tests/test_tab_smooth.py b/source/tests/tf/test_tab_smooth.py similarity index 98% rename from source/tests/test_tab_smooth.py rename to source/tests/tf/test_tab_smooth.py index f823b366c8..e0cf564cd6 100644 --- a/source/tests/test_tab_smooth.py +++ b/source/tests/tf/test_tab_smooth.py @@ -3,16 +3,6 @@ import unittest import numpy as np -from common import ( - Data, - force_dw_test, - force_test, - virial_dw_test, - virial_test, -) -from test_descrpt_smooth import ( - Inter, -) # load grad of force module from deepmd.tf.env import ( @@ -23,6 +13,17 @@ PairTab, ) +from .common import ( + Data, + force_dw_test, + force_test, + virial_dw_test, + virial_test, +) +from .test_descrpt_smooth import ( + Inter, +) + def _make_tab(ntype): xx = np.arange(0, 9, 0.001) diff --git a/source/tests/test_tabulate.py b/source/tests/tf/test_tabulate.py similarity index 100% rename from source/tests/test_tabulate.py rename to source/tests/tf/test_tabulate.py diff --git a/source/tests/test_train.py b/source/tests/tf/test_train.py similarity index 100% rename from source/tests/test_train.py rename to source/tests/tf/test_train.py diff --git a/source/tests/test_transfer.py b/source/tests/tf/test_transfer.py similarity index 98% rename from source/tests/test_transfer.py rename to source/tests/tf/test_transfer.py index f73c9eef66..e5b7f0a906 100644 --- a/source/tests/test_transfer.py +++ b/source/tests/tf/test_transfer.py @@ -4,10 +4,6 @@ import unittest import numpy as np -from common import ( - run_dp, - tests_path, -) from deepmd.tf.env import ( GLOBAL_NP_FLOAT_PRECISION, @@ -19,6 +15,12 @@ convert_pbtxt_to_pb, ) +from .common import ( + infer_path, + run_dp, + tests_path, +) + if GLOBAL_NP_FLOAT_PRECISION == np.float32: default_places = 4 else: @@ -48,10 +50,10 @@ def setUpClass(self): self.raw_model = str(tests_path / "dp-raw.pb") self.new_model = str(tests_path / "dp-new.pb") convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "deeppot.pbtxt")), self.old_model + str(infer_path / os.path.join("deeppot.pbtxt")), self.old_model ) convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "deeppot-1.pbtxt")), self.raw_model + str(infer_path / os.path.join("deeppot-1.pbtxt")), self.raw_model ) ret = run_dp( "dp transfer -O " diff --git a/source/tests/test_type_embed.py b/source/tests/tf/test_type_embed.py similarity index 100% rename from source/tests/test_type_embed.py rename to source/tests/tf/test_type_embed.py diff --git a/source/tests/test_type_one_side.py b/source/tests/tf/test_type_one_side.py similarity index 99% rename from source/tests/test_type_one_side.py rename to source/tests/tf/test_type_one_side.py index d1c02981e7..5c71a41739 100644 --- a/source/tests/test_type_one_side.py +++ b/source/tests/tf/test_type_one_side.py @@ -1,10 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import numpy as np -from common import ( - DataSystem, - gen_data, - j_loader, -) from deepmd.tf.common import ( j_must_have, @@ -16,6 +11,12 @@ tf, ) +from .common import ( + DataSystem, + gen_data, + j_loader, +) + GLOBAL_ENER_FLOAT_PRECISION = tf.float64 GLOBAL_TF_FLOAT_PRECISION = tf.float64 GLOBAL_NP_FLOAT_PRECISION = np.float64 diff --git a/source/tests/test_virtual_type.py b/source/tests/tf/test_virtual_type.py similarity index 97% rename from source/tests/test_virtual_type.py rename to source/tests/tf/test_virtual_type.py index 0aca54dfd6..5ceb1c7637 100644 --- a/source/tests/test_virtual_type.py +++ b/source/tests/tf/test_virtual_type.py @@ -4,11 +4,6 @@ import unittest import numpy as np -from common import ( - gen_data, - j_loader, - tests_path, -) from deepmd.tf.common import ( j_must_have, @@ -26,12 +21,18 @@ NeighborStat, ) +from .common import ( + gen_data, + infer_path, + j_loader, +) + class TestVirtualType(unittest.TestCase): @classmethod def setUpClass(cls): convert_pbtxt_to_pb( - str(tests_path / os.path.join("infer", "virtual_type.pbtxt")), + str(infer_path / os.path.join("virtual_type.pbtxt")), "virtual_type.pb", ) cls.dp = DeepPot("virtual_type.pb") diff --git a/source/tests/train_dos.json b/source/tests/tf/train_dos.json similarity index 100% rename from source/tests/train_dos.json rename to source/tests/tf/train_dos.json diff --git a/source/tests/water.json b/source/tests/tf/water.json similarity index 100% rename from source/tests/water.json rename to source/tests/tf/water.json diff --git a/source/tests/water_hybrid.json b/source/tests/tf/water_hybrid.json similarity index 100% rename from source/tests/water_hybrid.json rename to source/tests/tf/water_hybrid.json diff --git a/source/tests/water_layer_name.json b/source/tests/tf/water_layer_name.json similarity index 100% rename from source/tests/water_layer_name.json rename to source/tests/tf/water_layer_name.json diff --git a/source/tests/water_multi.json b/source/tests/tf/water_multi.json similarity index 100% rename from source/tests/water_multi.json rename to source/tests/tf/water_multi.json diff --git a/source/tests/water_se_a.json b/source/tests/tf/water_se_a.json similarity index 100% rename from source/tests/water_se_a.json rename to source/tests/tf/water_se_a.json diff --git a/source/tests/water_se_a_afparam.json b/source/tests/tf/water_se_a_afparam.json similarity index 100% rename from source/tests/water_se_a_afparam.json rename to source/tests/tf/water_se_a_afparam.json diff --git a/source/tests/water_se_a_aparam.json b/source/tests/tf/water_se_a_aparam.json similarity index 100% rename from source/tests/water_se_a_aparam.json rename to source/tests/tf/water_se_a_aparam.json diff --git a/source/tests/water_se_a_ebd.json b/source/tests/tf/water_se_a_ebd.json similarity index 100% rename from source/tests/water_se_a_ebd.json rename to source/tests/tf/water_se_a_ebd.json diff --git a/source/tests/water_se_a_fparam.json b/source/tests/tf/water_se_a_fparam.json similarity index 100% rename from source/tests/water_se_a_fparam.json rename to source/tests/tf/water_se_a_fparam.json diff --git a/source/tests/water_se_a_srtab.json b/source/tests/tf/water_se_a_srtab.json similarity index 100% rename from source/tests/water_se_a_srtab.json rename to source/tests/tf/water_se_a_srtab.json diff --git a/source/tests/water_se_a_type.json b/source/tests/tf/water_se_a_type.json similarity index 100% rename from source/tests/water_se_a_type.json rename to source/tests/tf/water_se_a_type.json diff --git a/source/tests/water_se_atten.json b/source/tests/tf/water_se_atten.json similarity index 100% rename from source/tests/water_se_atten.json rename to source/tests/tf/water_se_atten.json diff --git a/source/tests/water_se_atten_compressible_mixed_type.json b/source/tests/tf/water_se_atten_compressible_mixed_type.json similarity index 100% rename from source/tests/water_se_atten_compressible_mixed_type.json rename to source/tests/tf/water_se_atten_compressible_mixed_type.json diff --git a/source/tests/water_se_atten_mixed_type.json b/source/tests/tf/water_se_atten_mixed_type.json similarity index 100% rename from source/tests/water_se_atten_mixed_type.json rename to source/tests/tf/water_se_atten_mixed_type.json diff --git a/source/tests/water_se_r.json b/source/tests/tf/water_se_r.json similarity index 100% rename from source/tests/water_se_r.json rename to source/tests/tf/water_se_r.json diff --git a/source/tests/water_se_t.json b/source/tests/tf/water_se_t.json similarity index 100% rename from source/tests/water_se_t.json rename to source/tests/tf/water_se_t.json diff --git a/source/tests/wfc.json b/source/tests/tf/wfc.json similarity index 100% rename from source/tests/wfc.json rename to source/tests/tf/wfc.json diff --git a/source/tests/yaml_inputs/water_se_a_v1.json b/source/tests/tf/yaml_inputs/water_se_a_v1.json similarity index 100% rename from source/tests/yaml_inputs/water_se_a_v1.json rename to source/tests/tf/yaml_inputs/water_se_a_v1.json diff --git a/source/tests/yaml_inputs/water_se_a_v1.yaml b/source/tests/tf/yaml_inputs/water_se_a_v1.yaml similarity index 100% rename from source/tests/yaml_inputs/water_se_a_v1.yaml rename to source/tests/tf/yaml_inputs/water_se_a_v1.yaml diff --git a/source/tests/yaml_inputs/water_v1.json b/source/tests/tf/yaml_inputs/water_v1.json similarity index 100% rename from source/tests/yaml_inputs/water_v1.json rename to source/tests/tf/yaml_inputs/water_v1.json diff --git a/source/tests/yaml_inputs/water_v1.yaml b/source/tests/tf/yaml_inputs/water_v1.yaml similarity index 100% rename from source/tests/yaml_inputs/water_v1.yaml rename to source/tests/tf/yaml_inputs/water_v1.yaml diff --git a/source/tests/zinc_se_a_mask.json b/source/tests/tf/zinc_se_a_mask.json similarity index 100% rename from source/tests/zinc_se_a_mask.json rename to source/tests/tf/zinc_se_a_mask.json