Skip to content

Commit

Permalink
Updating current tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kartographer committed Jan 27, 2025
1 parent ea65356 commit 5d8f4d1
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 13 deletions.
6 changes: 5 additions & 1 deletion tests/test_beam_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,8 @@ def test_with_feeds_ordering_power(gaussian_uv):
assert np.all(intf_feedx.polarization_array == [-5, -6, -7, -8])

intf_feedyx = intf.with_feeds(["y", "x"], maintain_ordering=False)
assert np.all(intf_feedyx.polarization_array == [-6, -8, -7, -5])
# N.b. (Karto), this used to check against [-6, -8, -7, -5], but I _think_ this
# was actually a bug, in that UVBeam.select was sensitive to the ordering of
# pol arguments for polarization_array *only*, and not anything else with a
# polarization axis.
assert np.all(intf_feedyx.polarization_array == [-5, -6, -7, -8])
2 changes: 2 additions & 0 deletions tests/utils/test_bls.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def test_antnums_to_baseline_miriad_convention():
np.testing.assert_allclose(bl, bl_gold)


@pytest.mark.filterwarnings("ignore:antnums_to_baseline")
@pytest.mark.skipif(not hasbench, reason="benchmark utility not installed")
@pytest.mark.parametrize(
"nbls", [1, 10, 100, 1000, 10000, 100000, 1000000], ids=lambda x: f"len={x:}"
Expand Down Expand Up @@ -69,6 +70,7 @@ def test_bls_to_ant(benchmark, bl_start, nbls):
assert np.array_equal(bls, bls_out)


@pytest.mark.filterwarnings("ignore:antnums_to_baseline")
@pytest.mark.skipif(not hasbench, reason="benchmark utility not installed")
@pytest.mark.parametrize(
"nbls", [1, 10, 100, 1000, 10000, 100000, 1000000], ids=lambda x: f"len={x:}"
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def test_astrometry_lst(astrometry_args):
"""
Check for consistency beteen astrometry libraries when calculating LAST
Check for consistency between astrometry libraries when calculating LAST
This test evaluates consistency in calculating local apparent sidereal time when
using the different astrometry libraries available in pyuvdata, namely: astropy,
Expand Down
4 changes: 2 additions & 2 deletions tests/uvbeam/test_uvbeam.py
Original file line number Diff line number Diff line change
Expand Up @@ -2120,12 +2120,12 @@ def test_select_polarizations_errors(cst_efield_1freq):

# check for errors associated with polarizations not included in data
with pytest.raises(
ValueError, match=f"polarization {-3} is not present in the polarization_array"
ValueError, match=f"Polarization {-3} is not present in the polarization_array"
):
power_beam.select(polarizations=[-3, -4])

# check for warnings and errors associated with unevenly spaced polarizations
with check_warnings(UserWarning, "Selected polarizations are not evenly spaced"):
with check_warnings(UserWarning, "Selected polarization values are not evenly"):
power_beam.select(polarizations=power_beam.polarization_array[[0, 1, 3]])
write_file_beamfits = os.path.join(DATA_PATH, "test/select_beam.fits")
with pytest.raises(
Expand Down
12 changes: 8 additions & 4 deletions tests/uvcal/test_uvcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,10 @@ def test_select_frequencies_multispw(multi_spw_gain, tmp_path):
calobj2.write_calfits(write_file_calfits, clobber=True)

calobj3 = calobj.select(spws=[1], inplace=False)

# We've used different selection criteria, so the history _will_ be different
calobj3.history = calobj2.history

assert calobj3 == calobj2
with check_warnings(UserWarning, match="Cannot select on spws if Nspws=1."):
calobj3.select(spws=1)
Expand Down Expand Up @@ -4457,8 +4461,8 @@ def test_flex_jones_select_err(multi_spw_gain):
multi_spw_gain += uvc_spoof
multi_spw_gain.convert_to_flex_jones()

with pytest.raises(ValueError, match="this Jones selection in this flex-Jones"):
multi_spw_gain.select(jones=-6, spws=1)
with pytest.raises(ValueError, match="No data matching this Jones term"):
multi_spw_gain.select(jones=[-6], spws=1)


def test_remove_flex_jones_dup_err(multi_spw_gain):
Expand All @@ -4483,8 +4487,8 @@ def test_flex_jones_shuffle(multi_spw_gain, multi_spw_delay, mode):
uvc += uvc_spoof
uvc.convert_to_flex_jones()

uvc1 = uvc.select(jones=-5, inplace=False)
uvc2 = uvc.select(jones=-6, inplace=False)
uvc1 = uvc.select(jones=[-5], inplace=False)
uvc2 = uvc.select(jones=[-6], inplace=False)

assert uvc1 != uvc2

Expand Down
6 changes: 2 additions & 4 deletions tests/uvdata/test_mir.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def test_flex_pol_select(sma_mir_filt):
sma_mir_filt2 += sma_mir_filt3

with check_warnings(
UserWarning, match="Selected polarization values are not evenly spaced"
UserWarning, match="Selected polarizations are not evenly spaced"
):
sma_mir_filt2.select(polarizations=["xx", "xy", "yx"])

Expand All @@ -541,9 +541,7 @@ def test_flex_pol_select_warning(sma_mir_filt):
sma_mir_filt.flex_spw_polarization_array = np.array([-8, -8, -6, -5])
sma_mir_filt.Nspws = 4

with check_warnings(
UserWarning, "Selected polarization values are not evenly spaced."
):
with check_warnings(UserWarning, "Selected polarizations are not evenly spaced."):
sma_mir_filt.select(polarizations=[-8, -6, -5])


Expand Down
2 changes: 2 additions & 0 deletions tests/uvdata/test_mwa_corr_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,7 @@ def test_read_mwax(benchmark, tmp_path):
assert mwax_uv == uvfits_uv


@pytest.mark.filterwarnings("ignore:some coarse channel files were not submitted")
@pytest.mark.skipif(not hasbench, reason="benchmark utility not installed")
def test_corr_fits_select_on_read(benchmark):
mwa_uv = UVData()
Expand Down Expand Up @@ -1311,6 +1312,7 @@ def test_corr_fits_select_on_read(benchmark):
assert mwa_uv == mwa_uv2


@pytest.mark.filterwarnings("ignore:some coarse channel files were not submitted")
@pytest.mark.skipif(not hasbench, reason="benchmark utility not installed")
@pytest.mark.parametrize("cheby", [True, False], ids=lambda x: f"cheby={x:}")
def test_van_vleck(benchmark, cheby):
Expand Down
6 changes: 6 additions & 0 deletions tests/uvdata/test_uvdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -11917,12 +11917,18 @@ def test_remove_flex_pol_no_op_multiple_spws(uv_phase_comp):
uvd2.flex_spw_id_array[: uvd2.Nfreqs // 3] = 1
uvd2.flex_spw_id_array[uvd2.Nfreqs // 3 : 2 * (uvd2.Nfreqs // 3)] = 4
uvd2.flex_spw_id_array[2 * (uvd2.Nfreqs // 3) :] = 5
print(np.unique(uvd2.flex_spw_id_array))
print(uvd2.spw_array)
uvd2.check()
uvd3 = uvd2.copy()

uvd2.convert_to_flex_pol()
print(np.unique(uvd2.flex_spw_id_array))
print(uvd2.spw_array)
uvd2.select(polarizations=["xx"])
uvd2.remove_flex_pol()
print(np.unique(uvd2.flex_spw_id_array))
print(uvd2.spw_array)

uvd3.select(polarizations=["xx"])
assert uvd2 == uvd3
Expand Down
2 changes: 1 addition & 1 deletion tests/uvflag/test_uvflag.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ def test_read_write_loop_missing_telescope_info(
if uv_mod is None:
if param_list == ["antenna_names"]:
assert not np.array_equal(
uvf2.telescope.antenna_names, uvf.telescope.antenna_numbers
uvf2.telescope.antenna_names, uvf.telescope.antenna_names
)
uvf2.telescope.antenna_names = uvf.telescope.antenna_names
else:
Expand Down

0 comments on commit 5d8f4d1

Please sign in to comment.