Skip to content

Commit 565f0af

Browse files
fix: relax atol and rtol value of padding atoms UT (#4892)
The UT of padding atoms(pytorch backend) sometimes fails like: ``` Mismatched elements: 1 / 2 (50%) Max absolute difference among violations: 1.97471693e-08 Max relative difference among violations: 6.45619919e-07 ACTUAL: array([[-0.236542], [ 0.030586]]) DESIRED: array([[-0.236542], [ 0.030586]]) = 1 failed, 15442 passed, 4135 skipped, 97877 deselected, 224 warnings in 2825.25s (0:47:05) = ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Tests** - Adjusted numerical comparison assertions to use both absolute and relative tolerances in padding-related tests. - Aligns checks between computed results and references, improving resilience to minor floating-point variation. - Reduces intermittent test failures across environments and dependency versions. - No impact on features, performance, or user workflows. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent e73bbff commit 565f0af

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

source/tests/pt/test_padding_atoms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def setUp(self) -> None:
4949
self.sel = [16, 8]
5050
self.rcut = 2.2
5151
self.rcut_smth = 0.4
52-
self.atol = 1e-8
52+
self.atol = 1e-6
53+
self.rtol = 1e-5
5354

5455

5556
class TestPaddingAtoms(unittest.TestCase, TestCaseSingleFrameWithoutNlist):
@@ -79,6 +80,7 @@ def test_padding_atoms_consistency(self):
7980
to_numpy_array(result[var_name].cpu().detach()),
8081
np.mean(to_numpy_array(result[f"atom_{var_name}"].cpu().detach()), axis=1),
8182
atol=self.atol,
83+
rtol=self.rtol,
8284
)
8385
# test padding atoms
8486
padding_atoms_list = [1, 5, 10]
@@ -105,6 +107,7 @@ def test_padding_atoms_consistency(self):
105107
to_numpy_array(result[var_name].cpu().detach()),
106108
to_numpy_array(result_padding[var_name].cpu().detach()),
107109
atol=self.atol,
110+
rtol=self.rtol,
108111
)
109112

110113

0 commit comments

Comments
 (0)