From 1f094378eae0d3686df49e5aff12331578ba5c47 Mon Sep 17 00:00:00 2001 From: Duo <50307526+iProzd@users.noreply.github.com> Date: Fri, 26 Jan 2024 20:00:27 +0800 Subject: [PATCH] Revert "fix NoneType self.model in UTs" This reverts commit 8082b4981da4468ea06107e756b74f327b1d2f82. --- source/tests/pt/test_autodiff.py | 24 --------------------- source/tests/pt/test_permutation.py | 22 +------------------ source/tests/pt/test_permutation_denoise.py | 10 +-------- source/tests/pt/test_rot.py | 22 +------------------ source/tests/pt/test_rot_denoise.py | 10 +-------- source/tests/pt/test_trans.py | 22 +------------------ source/tests/pt/test_trans_denoise.py | 13 +---------- 7 files changed, 6 insertions(+), 117 deletions(-) diff --git a/source/tests/pt/test_autodiff.py b/source/tests/pt/test_autodiff.py index df36e9a4e4..1127dbc973 100644 --- a/source/tests/pt/test_autodiff.py +++ b/source/tests/pt/test_autodiff.py @@ -47,9 +47,6 @@ def stretch_box(old_coord, old_box, new_box): class TestForce: - def __init__(self): - self.model = None - def test( self, ): @@ -88,9 +85,6 @@ def ff(_coord): class TestVirial: - def __init__(self): - self.model = None - def test( self, ): @@ -135,9 +129,6 @@ def ff(bb): class TestEnergyModelSeAForce(unittest.TestCase, TestForce): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_se_e2_a) sampled = make_sample(model_params) @@ -146,9 +137,6 @@ def setUp(self): class TestEnergyModelSeAVirial(unittest.TestCase, TestVirial): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_se_e2_a) sampled = make_sample(model_params) @@ -157,9 +145,6 @@ def setUp(self): class TestEnergyModelDPA1Force(unittest.TestCase, TestForce): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_dpa1) sampled = make_sample(model_params) @@ -168,9 +153,6 @@ def setUp(self): class TestEnergyModelDPA1Virial(unittest.TestCase, TestVirial): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_dpa1) sampled = make_sample(model_params) @@ -179,9 +161,6 @@ def setUp(self): class TestEnergyModelDPA2Force(unittest.TestCase, TestForce): - def __init__(self): - super().__init__() - def setUp(self): model_params_sample = copy.deepcopy(model_dpa2) model_params_sample["descriptor"]["rcut"] = model_params_sample["descriptor"][ @@ -197,9 +176,6 @@ def setUp(self): class TestEnergyModelDPAUniVirial(unittest.TestCase, TestVirial): - def __init__(self): - super().__init__() - def setUp(self): model_params_sample = copy.deepcopy(model_dpa2) model_params_sample["descriptor"]["rcut"] = model_params_sample["descriptor"][ diff --git a/source/tests/pt/test_permutation.py b/source/tests/pt/test_permutation.py index 2d11ceb57e..11cb4ad23e 100644 --- a/source/tests/pt/test_permutation.py +++ b/source/tests/pt/test_permutation.py @@ -197,12 +197,10 @@ def make_sample(model_params): class TestPermutation: - def __init__(self): - self.model = None - def test( self, ): + self.model = None natoms = 5 cell = torch.rand([3, 3], dtype=dtype).to(env.DEVICE) cell = (cell + cell.T) + 5.0 * torch.eye(3).to(env.DEVICE) @@ -238,9 +236,6 @@ def test( class TestEnergyModelSeA(unittest.TestCase, TestPermutation): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_se_e2_a) sampled = make_sample(model_params) @@ -249,9 +244,6 @@ def setUp(self): class TestEnergyModelDPA1(unittest.TestCase, TestPermutation): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_dpa1) sampled = make_sample(model_params) @@ -260,9 +252,6 @@ def setUp(self): class TestEnergyModelDPA2(unittest.TestCase, TestPermutation): - def __init__(self): - super().__init__() - def setUp(self): model_params_sample = copy.deepcopy(model_dpa2) model_params_sample["descriptor"]["rcut"] = model_params_sample["descriptor"][ @@ -278,9 +267,6 @@ def setUp(self): class TestForceModelDPA2(unittest.TestCase, TestPermutation): - def __init__(self): - super().__init__() - def setUp(self): model_params_sample = copy.deepcopy(model_dpa2) model_params_sample["descriptor"]["rcut"] = model_params_sample["descriptor"][ @@ -299,9 +285,6 @@ def setUp(self): @unittest.skip("hybrid not supported at the moment") class TestEnergyModelHybrid(unittest.TestCase, TestPermutation): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_hybrid) sampled = make_sample(model_params) @@ -311,9 +294,6 @@ def setUp(self): @unittest.skip("hybrid not supported at the moment") class TestForceModelHybrid(unittest.TestCase, TestPermutation): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_hybrid) model_params["fitting_net"]["type"] = "direct_force_ener" diff --git a/source/tests/pt/test_permutation_denoise.py b/source/tests/pt/test_permutation_denoise.py index 57d3f867d1..c913881b01 100644 --- a/source/tests/pt/test_permutation_denoise.py +++ b/source/tests/pt/test_permutation_denoise.py @@ -35,12 +35,10 @@ class TestPermutationDenoise: - def __init__(self): - self.model = None - def test( self, ): + self.model = None natoms = 5 cell = torch.rand([3, 3], dtype=dtype).to(env.DEVICE) cell = (cell + cell.T) + 5.0 * torch.eye(3).to(env.DEVICE) @@ -70,9 +68,6 @@ def test( class TestDenoiseModelDPA1(unittest.TestCase, TestPermutationDenoise): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_dpa1) sampled = make_sample(model_params) @@ -81,9 +76,6 @@ def setUp(self): class TestDenoiseModelDPA2(unittest.TestCase, TestPermutationDenoise): - def __init__(self): - super().__init__() - def setUp(self): model_params_sample = copy.deepcopy(model_dpa2) model_params_sample["descriptor"]["rcut"] = model_params_sample["descriptor"][ diff --git a/source/tests/pt/test_rot.py b/source/tests/pt/test_rot.py index 75250a090e..46cc6fface 100644 --- a/source/tests/pt/test_rot.py +++ b/source/tests/pt/test_rot.py @@ -26,12 +26,10 @@ class TestRot: - def __init__(self): - self.model = None - def test( self, ): + self.model = None prec = 1e-10 natoms = 5 cell = 10.0 * torch.eye(3, dtype=dtype).to(env.DEVICE) @@ -113,9 +111,6 @@ def test( class TestEnergyModelSeA(unittest.TestCase, TestRot): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_se_e2_a) sampled = make_sample(model_params) @@ -124,9 +119,6 @@ def setUp(self): class TestEnergyModelDPA1(unittest.TestCase, TestRot): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_dpa1) sampled = make_sample(model_params) @@ -135,9 +127,6 @@ def setUp(self): class TestEnergyModelDPA2(unittest.TestCase, TestRot): - def __init__(self): - super().__init__() - def setUp(self): model_params_sample = copy.deepcopy(model_dpa2) model_params_sample["descriptor"]["rcut"] = model_params_sample["descriptor"][ @@ -153,9 +142,6 @@ def setUp(self): class TestForceModelDPA2(unittest.TestCase, TestRot): - def __init__(self): - super().__init__() - def setUp(self): model_params_sample = copy.deepcopy(model_dpa2) model_params_sample["descriptor"]["rcut"] = model_params_sample["descriptor"][ @@ -174,9 +160,6 @@ def setUp(self): @unittest.skip("hybrid not supported at the moment") class TestEnergyModelHybrid(unittest.TestCase, TestRot): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_hybrid) sampled = make_sample(model_params) @@ -186,9 +169,6 @@ def setUp(self): @unittest.skip("hybrid not supported at the moment") class TestForceModelHybrid(unittest.TestCase, TestRot): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_hybrid) model_params["fitting_net"]["type"] = "direct_force_ener" diff --git a/source/tests/pt/test_rot_denoise.py b/source/tests/pt/test_rot_denoise.py index ce16b78942..8b83b065a9 100644 --- a/source/tests/pt/test_rot_denoise.py +++ b/source/tests/pt/test_rot_denoise.py @@ -24,12 +24,10 @@ class TestRotDenoise: - def __init__(self): - self.model = None - def test( self, ): + self.model = None prec = 1e-10 natoms = 5 cell = 10.0 * torch.eye(3, dtype=dtype).to(env.DEVICE) @@ -101,9 +99,6 @@ def test( class TestDenoiseModelDPA1(unittest.TestCase, TestRotDenoise): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_dpa1) sampled = make_sample(model_params) @@ -112,9 +107,6 @@ def setUp(self): class TestDenoiseModelDPA2(unittest.TestCase, TestRotDenoise): - def __init__(self): - super().__init__() - def setUp(self): model_params_sample = copy.deepcopy(model_dpa2) model_params_sample["descriptor"]["rcut"] = model_params_sample["descriptor"][ diff --git a/source/tests/pt/test_trans.py b/source/tests/pt/test_trans.py index 56e9a4055b..988c760a0a 100644 --- a/source/tests/pt/test_trans.py +++ b/source/tests/pt/test_trans.py @@ -26,12 +26,10 @@ class TestTrans: - def __init__(self): - self.model = None - def test( self, ): + self.model = None natoms = 5 cell = torch.rand([3, 3], dtype=dtype).to(env.DEVICE) cell = (cell + cell.T) + 5.0 * torch.eye(3).to(env.DEVICE) @@ -69,9 +67,6 @@ def test( class TestEnergyModelSeA(unittest.TestCase, TestTrans): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_se_e2_a) sampled = make_sample(model_params) @@ -80,9 +75,6 @@ def setUp(self): class TestEnergyModelDPA1(unittest.TestCase, TestTrans): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_dpa1) sampled = make_sample(model_params) @@ -91,9 +83,6 @@ def setUp(self): class TestEnergyModelDPA2(unittest.TestCase, TestTrans): - def __init__(self): - super().__init__() - def setUp(self): model_params_sample = copy.deepcopy(model_dpa2) model_params_sample["descriptor"]["rcut"] = model_params_sample["descriptor"][ @@ -109,9 +98,6 @@ def setUp(self): class TestForceModelDPA2(unittest.TestCase, TestTrans): - def __init__(self): - super().__init__() - def setUp(self): model_params_sample = copy.deepcopy(model_dpa2) model_params_sample["descriptor"]["rcut"] = model_params_sample["descriptor"][ @@ -130,9 +116,6 @@ def setUp(self): @unittest.skip("hybrid not supported at the moment") class TestEnergyModelHybrid(unittest.TestCase, TestTrans): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_hybrid) sampled = make_sample(model_params) @@ -142,9 +125,6 @@ def setUp(self): @unittest.skip("hybrid not supported at the moment") class TestForceModelHybrid(unittest.TestCase, TestTrans): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_hybrid) model_params["fitting_net"]["type"] = "direct_force_ener" diff --git a/source/tests/pt/test_trans_denoise.py b/source/tests/pt/test_trans_denoise.py index 3e493140ef..f685a00f05 100644 --- a/source/tests/pt/test_trans_denoise.py +++ b/source/tests/pt/test_trans_denoise.py @@ -25,12 +25,10 @@ class TestTransDenoise: - def __init__(self): - self.model = None - def test( self, ): + self.model = None natoms = 5 cell = torch.rand([3, 3], dtype=dtype).to(env.DEVICE) cell = (cell + cell.T) + 5.0 * torch.eye(3).to(env.DEVICE) @@ -60,9 +58,6 @@ def test( class TestDenoiseModelDPA1(unittest.TestCase, TestTransDenoise): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_dpa1) sampled = make_sample(model_params) @@ -71,9 +66,6 @@ def setUp(self): class TestDenoiseModelDPA2(unittest.TestCase, TestTransDenoise): - def __init__(self): - super().__init__() - def setUp(self): model_params_sample = copy.deepcopy(model_dpa2) model_params_sample["descriptor"]["rcut"] = model_params_sample["descriptor"][ @@ -90,9 +82,6 @@ def setUp(self): @unittest.skip("hybrid not supported at the moment") class TestDenoiseModelHybrid(unittest.TestCase, TestTransDenoise): - def __init__(self): - super().__init__() - def setUp(self): model_params = copy.deepcopy(model_hybrid) sampled = make_sample(model_params)