-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
import unittest | ||
|
||
import numpy as np | ||
|
||
from deepmd.dpmodel.descriptor import ( | ||
DescrptSeR, | ||
) | ||
|
||
from .case_single_frame_with_nlist import ( | ||
TestCaseSingleFrameWithNlist, | ||
) | ||
|
||
|
||
class TestDescrptSeR(unittest.TestCase, TestCaseSingleFrameWithNlist): | ||
def setUp(self): | ||
TestCaseSingleFrameWithNlist.setUp(self) | ||
|
||
def test_self_consistency( | ||
self, | ||
): | ||
rng = np.random.default_rng() | ||
nf, nloc, nnei = self.nlist.shape | ||
davg = rng.normal(size=(self.nt, nnei, 1)) | ||
dstd = rng.normal(size=(self.nt, nnei, 1)) | ||
dstd = 0.1 + np.abs(dstd) | ||
|
||
em0 = DescrptSeR(self.rcut, self.rcut_smth, self.sel) | ||
em0.davg = davg | ||
em0.dstd = dstd | ||
em1 = DescrptSeR.deserialize(em0.serialize()) | ||
mm0 = em0.call(self.coord_ext, self.atype_ext, self.nlist) | ||
mm1 = em1.call(self.coord_ext, self.atype_ext, self.nlist) | ||
for ii in [0, 4]: | ||
np.testing.assert_allclose(mm0[ii], mm1[ii]) |