@@ -44,8 +44,7 @@ def test_1frame_atm(self):
4444 nsel = 2
4545 self .assertEqual (dd .shape , (nframes ,nsel ,3 ))
4646 # check values
47- for ii in range (dd .size ):
48- self .assertAlmostEqual (dd .reshape ([- 1 ])[ii ], self .expected_d .reshape ([- 1 ])[ii ], places = default_places )
47+ np .testing .assert_almost_equal (dd .ravel (), self .expected_d , default_places )
4948
5049 def test_2frame_atm (self ):
5150 coords2 = np .concatenate ((self .coords , self .coords ))
@@ -58,8 +57,7 @@ def test_2frame_atm(self):
5857 self .assertEqual (dd .shape , (nframes ,nsel ,3 ))
5958 # check values
6059 expected_d = np .concatenate ((self .expected_d , self .expected_d ))
61- for ii in range (dd .size ):
62- self .assertAlmostEqual (dd .reshape ([- 1 ])[ii ], expected_d .reshape ([- 1 ])[ii ], places = default_places )
60+ np .testing .assert_almost_equal (dd .ravel (), expected_d , default_places )
6361
6462
6563class TestDeepDipoleNoPBC (unittest .TestCase ) :
@@ -87,8 +85,7 @@ def test_1frame_atm(self):
8785 nsel = 2
8886 self .assertEqual (dd .shape , (nframes ,nsel ,3 ))
8987 # check values
90- for ii in range (dd .size ):
91- self .assertAlmostEqual (dd .reshape ([- 1 ])[ii ], self .expected_d .reshape ([- 1 ])[ii ], places = default_places )
88+ np .testing .assert_almost_equal (dd .ravel (), self .expected_d , default_places )
9289
9390 def test_1frame_atm_large_box (self ):
9491 dd = self .dp .eval (self .coords , self .box , self .atype )
@@ -98,8 +95,7 @@ def test_1frame_atm_large_box(self):
9895 nsel = 2
9996 self .assertEqual (dd .shape , (nframes ,nsel ,3 ))
10097 # check values
101- for ii in range (dd .size ):
102- self .assertAlmostEqual (dd .reshape ([- 1 ])[ii ], self .expected_d .reshape ([- 1 ])[ii ], places = default_places )
98+ np .testing .assert_almost_equal (dd .ravel (), self .expected_d , default_places )
10399
104100
105101@unittest .skipIf (parse_version (tf .__version__ ) < parse_version ("1.15" ),
@@ -138,8 +134,7 @@ def test_1frame_old(self):
138134 nframes = 1
139135 self .assertEqual (gt .shape , (nframes ,self .nout ))
140136 # check values
141- for ii in range (gt .size ):
142- self .assertAlmostEqual (gt .reshape ([- 1 ])[ii ], self .expected_gt .reshape ([- 1 ])[ii ], places = default_places )
137+ np .testing .assert_almost_equal (gt .ravel (), self .expected_gt , default_places )
143138
144139 def test_1frame_old_atm (self ):
145140 at = self .dp .eval (self .coords , self .box , self .atype )
@@ -149,8 +144,7 @@ def test_1frame_old_atm(self):
149144 nsel = 2
150145 self .assertEqual (at .shape , (nframes ,nsel ,self .nout ))
151146 # check values
152- for ii in range (at .size ):
153- self .assertAlmostEqual (at .reshape ([- 1 ])[ii ], self .expected_t .reshape ([- 1 ])[ii ], places = default_places )
147+ np .testing .assert_almost_equal (at .ravel (), self .expected_t , default_places )
154148
155149 def test_2frame_old_atm (self ):
156150 coords2 = np .concatenate ((self .coords , self .coords ))
@@ -163,8 +157,7 @@ def test_2frame_old_atm(self):
163157 self .assertEqual (at .shape , (nframes ,nsel ,self .nout ))
164158 # check values
165159 expected_d = np .concatenate ((self .expected_t , self .expected_t ))
166- for ii in range (at .size ):
167- self .assertAlmostEqual (at .reshape ([- 1 ])[ii ], expected_d .reshape ([- 1 ])[ii ], places = default_places )
160+ np .testing .assert_almost_equal (at .ravel (), expected_d , default_places )
168161
169162 def test_1frame_full (self ):
170163 gt , ff , vv = self .dp .eval_full (self .coords , self .box , self .atype , atomic = False )
@@ -175,12 +168,9 @@ def test_1frame_full(self):
175168 self .assertEqual (ff .shape , (nframes ,self .nout ,natoms ,3 ))
176169 self .assertEqual (vv .shape , (nframes ,self .nout ,9 ))
177170 # check values
178- for ii in range (ff .size ):
179- self .assertAlmostEqual (ff .reshape ([- 1 ])[ii ], self .expected_f .reshape ([- 1 ])[ii ], places = default_places )
180- for ii in range (gt .size ):
181- self .assertAlmostEqual (gt .reshape ([- 1 ])[ii ], self .expected_gt .reshape ([- 1 ])[ii ], places = default_places )
182- for ii in range (vv .size ):
183- self .assertAlmostEqual (vv .reshape ([- 1 ])[ii ], self .expected_gv .reshape ([- 1 ])[ii ], places = default_places )
171+ np .testing .assert_almost_equal (ff .ravel (), self .expected_f , default_places )
172+ np .testing .assert_almost_equal (gt .ravel (), self .expected_gt , default_places )
173+ np .testing .assert_almost_equal (vv .ravel (), self .expected_gv , default_places )
184174
185175 def test_1frame_full_atm (self ):
186176 gt , ff , vv , at , av = self .dp .eval_full (self .coords , self .box , self .atype , atomic = True )
0 commit comments