@@ -73,8 +73,8 @@ def test_advection_zonal_periodic():
7373 PeriodicParticle = Particle .add_variable (Variable ("total_dlon" , initial = 0 ))
7474 pset = ParticleSet (fieldset , pclass = PeriodicParticle , lon = [0.5 ], lat = [0.5 ])
7575 pset .execute ([AdvectionEE , periodicBC ], runtime = np .timedelta64 (40 , "s" ), dt = np .timedelta64 (1 , "s" ))
76- assert np .isclose (pset .total_dlon [0 ], 4 , atol = 1e-5 )
77- assert np .isclose (pset .lon_nextloop [0 ], 0.5 , atol = 1e-5 )
76+ np .testing . assert_allclose (pset .total_dlon [0 ], 4 , atol = 1e-5 )
77+ np .testing . assert_allclose (pset .lon_nextloop [0 ], 0.5 , atol = 1e-5 )
7878
7979
8080def test_horizontal_advection_in_3D_flow (npart = 10 ):
@@ -92,7 +92,7 @@ def test_horizontal_advection_in_3D_flow(npart=10):
9292 pset .execute (AdvectionRK4 , runtime = np .timedelta64 (2 , "h" ), dt = np .timedelta64 (15 , "m" ))
9393
9494 expected_lon = pset .depth * (pset .time - fieldset .time_interval .left ) / np .timedelta64 (1 , "s" )
95- assert np .allclose (expected_lon , pset .lon_nextloop , atol = 1.0e-1 )
95+ np .testing . assert_allclose (expected_lon , pset .lon_nextloop , atol = 1.0e-1 )
9696
9797
9898@pytest .mark .parametrize ("direction" , ["up" , "down" ])
@@ -132,8 +132,8 @@ def SubmergeParticle(particle, fieldset, time): # pragma: no cover
132132 pset .execute (kernels , runtime = np .timedelta64 (11 , "s" ), dt = np .timedelta64 (1 , "s" ))
133133
134134 if direction == "up" and wErrorThroughSurface :
135- assert np .allclose (pset .lon [0 ], 0.6 )
136- assert np .allclose (pset .depth [0 ], 0 )
135+ np .testing . assert_allclose (pset .lon [0 ], 0.6 , atol = 1e-5 )
136+ np .testing . assert_allclose (pset .depth [0 ], 0 , atol = 1e-5 )
137137 else :
138138 assert len (pset ) == 0
139139
@@ -189,10 +189,10 @@ def test_length1dimensions(u, v, w): # TODO: Refactor this test to be more read
189189 pset .execute (kernel , runtime = np .timedelta64 (5 , "s" ), dt = np .timedelta64 (1 , "s" ))
190190
191191 assert len (pset .lon ) == len ([p .lon for p in pset ])
192- assert (( np .array ([p .lon - x0 for p in pset ]) - 4 * u ) < 1e-6 ). all ( )
193- assert (( np .array ([p .lat - y0 for p in pset ]) - 4 * v ) < 1e-6 ). all ( )
192+ np . testing . assert_allclose ( np .array ([p .lon - x0 for p in pset ]), 4 * u , atol = 1e-6 )
193+ np . testing . assert_allclose ( np .array ([p .lat - y0 for p in pset ]), 4 * v , atol = 1e-6 )
194194 if w :
195- assert (( np .array ([p .depth - z0 for p in pset ]) - 4 * w ) < 1e-6 ). all ( )
195+ np . testing . assert_allclose ( np .array ([p .depth - z0 for p in pset ]), 4 * w , atol = 1e-6 )
196196
197197
198198def test_radialrotation (npart = 10 ):
@@ -215,8 +215,8 @@ def test_radialrotation(npart=10):
215215 true_lon = (lon - 30.0 ) * np .cos (theta ) + 30.0
216216 true_lat = - (lon - 30.0 ) * np .sin (theta ) + 30.0
217217
218- assert np .allclose (pset .lon , true_lon , atol = 5e-2 )
219- assert np .allclose (pset .lat , true_lat , atol = 5e-2 )
218+ np .testing . assert_allclose (pset .lon , true_lon , atol = 5e-2 )
219+ np .testing . assert_allclose (pset .lat , true_lat , atol = 5e-2 )
220220
221221
222222@pytest .mark .parametrize (
@@ -271,10 +271,10 @@ def truth_moving(x_0, y_0, t):
271271 return lon , lat
272272
273273 exp_lon , exp_lat = truth_moving (start_lon , start_lat , pset .time_nextloop [0 ])
274- assert np .allclose (pset .lon_nextloop , exp_lon , rtol = rtol )
275- assert np .allclose (pset .lat_nextloop , exp_lat , rtol = rtol )
274+ np .testing . assert_allclose (pset .lon_nextloop , exp_lon , rtol = rtol )
275+ np .testing . assert_allclose (pset .lat_nextloop , exp_lat , rtol = rtol )
276276 if method == "RK4_3D" :
277- assert np .allclose (pset .depth_nextloop , exp_lat , rtol = rtol )
277+ np .testing . assert_allclose (pset .depth_nextloop , exp_lat , rtol = rtol )
278278
279279
280280@pytest .mark .parametrize (
@@ -321,8 +321,8 @@ def truth_moving(x_0, y_0, t):
321321 return lon , lat
322322
323323 exp_lon , exp_lat = truth_moving (start_lon , start_lat , pset .time_nextloop [0 ])
324- assert np .allclose (pset .lon_nextloop , exp_lon , rtol = rtol )
325- assert np .allclose (pset .lat_nextloop , exp_lat , rtol = rtol )
324+ np .testing . assert_allclose (pset .lon_nextloop , exp_lon , rtol = rtol )
325+ np .testing . assert_allclose (pset .lat_nextloop , exp_lat , rtol = rtol )
326326
327327
328328# TODO decrease atol for these tests once the C-grid is implemented
@@ -333,7 +333,7 @@ def truth_moving(x_0, y_0, t):
333333 ("RK45" , 1 ),
334334 ],
335335)
336- @pytest .mark .parametrize ("grid_type" , ["A" , "C" ])
336+ @pytest .mark .parametrize ("grid_type" , ["A" ]) # TODO also implement C-grid once available
337337@pytest .mark .parametrize ("flowfield" , ["stommel_gyre" , "peninsula" ])
338338def test_gyre_flowfields (method , grid_type , atol , flowfield ):
339339 npart = 2
0 commit comments