Skip to content

Commit 3f8888d

Browse files
committed
disentangle the progressbar from the backend; test all combinations
1 parent 5934a62 commit 3f8888d

File tree

6 files changed

+184
-98
lines changed

6 files changed

+184
-98
lines changed

pyuvsim/tests/test_profiler.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ def profdata_dir_setup(tmpdir):
2424
return outpath
2525

2626

27-
@pytest.mark.parametrize("backend", ["progsteps", "tqdm", "send_recv"])
27+
@pytest.mark.parametrize("backend", ["rma", "messaging", "send_recv"])
28+
@pytest.mark.parametrize("progbar", ["progsteps", "tqdm"])
2829
@pytest.mark.parallel(2)
29-
def test_profiler(tmpdir, backend):
30-
if backend != "progsteps":
30+
def test_profiler(tmpdir, backend, progbar):
31+
if progbar == "tqdm":
3132
pytest.importorskip("tqdm")
3233
line_profiler = pytest.importorskip('line_profiler')
3334
outpath = profdata_dir_setup(tmpdir)
@@ -37,7 +38,9 @@ def test_profiler(tmpdir, backend):
3738
with uvtest.check_warnings(UserWarning, match='Profiler already set'):
3839
pyuvsim.profiling.set_profiler(outfile_prefix=testprof_fname[:-4], dump_raw=True)
3940
param_filename = os.path.join(SIM_DATA_PATH, 'test_config', 'param_1time_1src_testcat.yaml')
40-
pyuvsim.uvsim.run_uvsim(param_filename, return_uv=True, backend=backend)
41+
pyuvsim.uvsim.run_uvsim(
42+
param_filename, return_uv=True, backend=backend, progbar=progbar
43+
)
4144
if pyuvsim.mpi.rank == 0:
4245
time_profiler = pyuvsim.profiling.get_profiler()
4346
time_profiler.disable_by_count()

pyuvsim/tests/test_run.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,16 @@ def test_run_paramfile_uvsim(goto_tempdir, paramfile):
7777

7878
@pytest.mark.filterwarnings("ignore:Input ra and dec parameters are being used instead")
7979
@pytest.mark.parametrize('model', ['monopole', 'cosza', 'quaddome', 'monopole-nonflat'])
80-
@pytest.mark.parametrize("backend", ["progsteps", "tqdm", "send_recv"])
80+
@pytest.mark.parametrize("backend", ["rma", "messaging", "send_recv"])
81+
@pytest.mark.parametrize("progbar", ["progsteps", "tqdm"])
8182
@pytest.mark.parallel(2)
82-
def test_analytic_diffuse(model, tmpdir, backend):
83+
def test_analytic_diffuse(model, tmpdir, backend, progbar):
8384
# Generate the given model and simulate for a few baselines.
8485
# Import from analytic_diffuse (consider moving to rasg_affiliates?)
8586
pytest.importorskip('analytic_diffuse')
8687
pytest.importorskip('astropy_healpix')
8788
import analytic_diffuse
88-
if backend != "progsteps":
89+
if progbar == "tqdm":
8990
pytest.importorskip("tqdm")
9091

9192
modname = model
@@ -134,7 +135,9 @@ def test_analytic_diffuse(model, tmpdir, backend):
134135
with open(obspar_path, 'w') as ofile:
135136
yaml.dump(obspar, ofile, default_flow_style=False)
136137

137-
uv_out = pyuvsim.run_uvsim(obspar_path, return_uv=True, backend=backend)
138+
uv_out = pyuvsim.run_uvsim(
139+
obspar_path, return_uv=True, backend=backend, progbar=progbar
140+
)
138141
if pyuvsim.mpi.rank == 0:
139142
# Convert from Jy to K sr
140143
dat = uv_out.data_array[:, 0, 0, 0] * jy_to_ksr(uv_out.freq_array[0, 0]).value
@@ -201,12 +204,13 @@ def test_run_gleam_uvsim(spectral_type):
201204
@pytest.mark.parametrize(
202205
"spectral_type",
203206
["subband", "spectral_index"])
204-
@pytest.mark.parametrize("backend", ["progsteps", "tqdm", "send_recv"])
207+
@pytest.mark.parametrize("backend", ["rma", "messaging", "send_recv"])
208+
@pytest.mark.parametrize("progbar", ["progsteps", "tqdm"])
205209
@pytest.mark.parallel(2)
206-
def test_zenith_spectral_sim(spectral_type, tmpdir, backend):
210+
def test_zenith_spectral_sim(spectral_type, tmpdir, backend, progbar):
207211
# Make a power law source at zenith in three ways.
208212
# Confirm that simulated visibilities match expectation.
209-
if backend in ["tqdm", "send_recv"]:
213+
if progbar == "tqdm":
210214
pytest.importorskip("tqdm")
211215

212216
params = pyuvsim.simsetup._config_str_to_dict(
@@ -242,7 +246,7 @@ def test_zenith_spectral_sim(spectral_type, tmpdir, backend):
242246
params['time']['start_time'] = kwds['time']
243247
params['select'] = {'antenna_nums' : [1, 2]}
244248

245-
uv_out = pyuvsim.run_uvsim(params, return_uv=True, backend=backend)
249+
uv_out = pyuvsim.run_uvsim(params, return_uv=True, backend=backend, progbar=progbar)
246250
if pyuvsim.mpi.rank == 0:
247251
for ii in range(uv_out.Nbls):
248252
assert np.allclose(uv_out.data_array[ii, 0, :, 0], spectrum / 2)
@@ -287,8 +291,8 @@ def test_sim_on_moon():
287291
assert uv_out.extra_keywords['world'] == 'moon'
288292

289293

290-
@pytest.mark.parametrize("backend", ["tqdm", "send_recv"])
291-
def test_npu_error_tqdm(backend):
294+
@pytest.mark.parametrize("backend", ["messaging", "send_recv"])
295+
def test_npu_error_backends(backend):
292296
pytest.importorskip("tqdm")
293297
params = pyuvsim.simsetup._config_str_to_dict(
294298
os.path.join(SIM_DATA_PATH, 'test_config', 'param_1time_1src_testcat.yaml')

pyuvsim/tests/test_uvsim.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -904,21 +904,27 @@ def test_tqdm_import_error():
904904
return
905905
except ImportError:
906906
with pytest.raises(ImportError, match="The tqdm module must be"):
907-
pyuvsim.uvsim._run_uvsim_tqdm(
908-
None, None, None, None, None, None, None, None, None,
909-
)
907+
pyuvsim.uvsim._get_pbar("tqdm", None, None)
910908

911909

912-
def test_send_recv_import_error():
910+
def test_progbar_error_get_pbar():
913911
pytest.importorskip('mpi4py')
914-
try:
915-
import tqdm # noqa
916-
return
917-
except ImportError:
918-
with pytest.raises(ImportError, match="The tqdm module must be"):
919-
pyuvsim.uvsim._run_uvsim_send_recv(
920-
None, None, None, None, None, None, None, None, None, None, None,
921-
)
912+
with pytest.raises(ValueError, match="The progbar keyword must be one of "):
913+
pyuvsim.uvsim._get_pbar("foo", None, None)
914+
915+
916+
def test_progbar_error_uvdata_uvsim():
917+
pytest.importorskip('mpi4py')
918+
with pytest.raises(ValueError, match="The progbar keyword must be one of "):
919+
pyuvsim.run_uvdata_uvsim(
920+
None, None, None, None, False, backend="rma", progbar="Foo"
921+
)
922+
923+
924+
def test_progbar_error_run_uvsim():
925+
pytest.importorskip('mpi4py')
926+
with pytest.raises(ValueError, match="The progbar keyword must be one of "):
927+
pyuvsim.run_uvsim(None, False, None, backend="rma", progbar="Foo")
922928

923929

924930
def test_backend_error_uvdata_uvsim():

0 commit comments

Comments
 (0)