1- from runtests . mpi import MPITest
1+ from mpi4py import MPI
22from nbodykit import setup_logging
33from nbodykit .binned_statistic import BinnedStatistic
44
1212setup_logging ("debug" )
1313
1414
15- @MPITest ([1 ])
15+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
16+ @pytest .mark .mpi
1617def test_to_json (comm ):
1718
1819 # load from JSON
@@ -30,7 +31,8 @@ def test_to_json(comm):
3031 # cleanup
3132 os .remove (ff .name )
3233
33- @MPITest ([1 ])
34+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
35+ @pytest .mark .mpi
3436def test_1d_load (comm ):
3537
3638 # load plaintext format
@@ -48,7 +50,8 @@ def test_1d_load(comm):
4850 for name in ds1 :
4951 testing .assert_almost_equal (ds1 [name ], ds2 [name ])
5052
51- @MPITest ([1 ])
53+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
54+ @pytest .mark .mpi
5255def test_2d_load (comm ):
5356
5457 # load plaintext format
@@ -62,7 +65,8 @@ def test_2d_load(comm):
6265 for name in ds1 :
6366 testing .assert_almost_equal (ds1 [name ], ds2 [name ])
6467
65- @MPITest ([1 ])
68+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
69+ @pytest .mark .mpi
6670def test_str (comm ):
6771
6872 dataset = BinnedStatistic .from_json (os .path .join (data_dir , 'dataset_2d.json' ))
@@ -78,7 +82,8 @@ def test_str(comm):
7882 # this is the same as str
7983 r = repr (dataset )
8084
81- @MPITest ([1 ])
85+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
86+ @pytest .mark .mpi
8287def test_getitem (comm ):
8388
8489 dataset = BinnedStatistic .from_json (os .path .join (data_dir , 'dataset_2d.json' ))
@@ -103,7 +108,8 @@ def test_getitem(comm):
103108 with pytest .raises (IndexError ):
104109 bad = dataset [0 ,0 ]
105110
106- @MPITest ([1 ])
111+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
112+ @pytest .mark .mpi
107113def test_array_slice (comm ):
108114
109115 dataset = BinnedStatistic .from_json (os .path .join (data_dir , 'dataset_2d.json' ))
@@ -121,7 +127,8 @@ def test_array_slice(comm):
121127 assert sliced .dims == ['k' , 'mu' ]
122128
123129
124- @MPITest ([1 ])
130+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
131+ @pytest .mark .mpi
125132def test_list_array_slice (comm ):
126133
127134 dataset = BinnedStatistic .from_json (os .path .join (data_dir , 'dataset_2d.json' ))
@@ -136,7 +143,8 @@ def test_list_array_slice(comm):
136143 testing .assert_array_equal (dataset [var ][:,[0 ,- 1 ]], sliced [var ])
137144
138145
139- @MPITest ([1 ])
146+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
147+ @pytest .mark .mpi
140148def test_variable_set (comm ):
141149
142150 dataset = BinnedStatistic .from_json (os .path .join (data_dir , 'dataset_2d.json' ))
@@ -155,15 +163,17 @@ def test_variable_set(comm):
155163 dataset ['TEST' ] = 10.
156164
157165
158- @MPITest ([1 ])
166+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
167+ @pytest .mark .mpi
159168def test_copy (comm ):
160169
161170 dataset = BinnedStatistic .from_json (os .path .join (data_dir , 'dataset_2d.json' ))
162171 copy = dataset .copy ()
163172 for var in dataset :
164173 testing .assert_array_equal (dataset [var ], copy [var ])
165174
166- @MPITest ([1 ])
175+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
176+ @pytest .mark .mpi
167177def test_rename_variable (comm ):
168178
169179 dataset = BinnedStatistic .from_json (os .path .join (data_dir , 'dataset_2d.json' ))
@@ -174,7 +184,8 @@ def test_rename_variable(comm):
174184 assert 'renamed_test' in dataset
175185 assert 'test' not in dataset
176186
177- @MPITest ([1 ])
187+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
188+ @pytest .mark .mpi
178189def test_sel (comm ):
179190
180191 dataset = BinnedStatistic .from_json (os .path .join (data_dir , 'dataset_2d.json' ))
@@ -200,7 +211,8 @@ def test_sel(comm):
200211 assert sliced .shape [1 ] == 1
201212 assert numpy .all ((sliced ['k' ] >= 0.02 )& (sliced ['k' ] <= 0.15 ))
202213
203- @MPITest ([1 ])
214+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
215+ @pytest .mark .mpi
204216def test_take (comm ):
205217
206218 dataset = BinnedStatistic .from_json (os .path .join (data_dir , 'dataset_2d.json' ))
@@ -222,7 +234,8 @@ def test_take(comm):
222234 dataset .take (dataset ['k' ] < 0.3 )
223235 assert len (sliced .dims ) == 2
224236
225- @MPITest ([1 ])
237+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
238+ @pytest .mark .mpi
226239def test_squeeze (comm ):
227240
228241 dataset = BinnedStatistic .from_json (os .path .join (data_dir , 'dataset_2d.json' ))
@@ -242,7 +255,8 @@ def test_squeeze(comm):
242255 assert squeezed .shape [0 ] == sliced .shape [0 ]
243256
244257
245- @MPITest ([1 ])
258+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
259+ @pytest .mark .mpi
246260def test_average (comm ):
247261 import warnings
248262
@@ -274,7 +288,8 @@ def test_average(comm):
274288 testing .assert_allclose (x , avg [var ])
275289
276290
277- @MPITest ([1 ])
291+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
292+ @pytest .mark .mpi
278293def test_reindex (comm ):
279294 import warnings
280295
@@ -297,7 +312,8 @@ def test_reindex(comm):
297312 new = dataset .reindex ('mu' , 0.4 , force = False )
298313 new = dataset .reindex ('mu' , 0.4 , force = True )
299314
300- @MPITest ([1 ])
315+ @pytest .mark .parametrize ("comm" , [MPI .COMM_WORLD ,])
316+ @pytest .mark .mpi
301317def test_subclass_copy_sel (comm ):
302318 # this test asserts the sel returns instance of subclass.
303319 # and the copy method can change the class.
0 commit comments