Skip to content

Commit

Permalink
Minor logic/test clean-up post rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
kartographer committed Dec 11, 2024
1 parent 85f7c00 commit 80e36af
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 34 deletions.
16 changes: 8 additions & 8 deletions src/pyuvdata/uvcal/uvcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1348,14 +1348,6 @@ def _add_phase_center(
info_source=info_source,
)

# We want to create a unique ID for each source, for use in indexing arrays.
# The logic below ensures that we pick the lowest positive integer that is
# not currently being used by another source
if cat_id is None:
cat_id = utils.phase_center_catalog.generate_new_phase_center_id(
phase_center_catalog=self.phase_center_catalog, cat_id=cat_id
)

if self.phase_center_catalog is None:
# Initialize an empty dict to plug entries into
self.phase_center_catalog = {}
Expand All @@ -1377,6 +1369,14 @@ def _add_phase_center(
"different ID and parameters."
)

# We want to create a unique ID for each source, for use in indexing arrays.
# The logic below ensures that we pick the lowest positive integer that is
# not currently being used by another source
if cat_id is None or not force_update:
cat_id = utils.phase_center_catalog.generate_new_phase_center_id(
phase_center_catalog=self.phase_center_catalog, cat_id=cat_id
)

# If source is unique, begin creating a dictionary for it
self.phase_center_catalog[cat_id] = cat_entry
self.Nphase = len(self.phase_center_catalog)
Expand Down
16 changes: 8 additions & 8 deletions src/pyuvdata/uvdata/uvdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,14 +805,6 @@ def _add_phase_center(
info_source=info_source,
)

# We want to create a unique ID for each source, for use in indexing arrays.
# The logic below ensures that we pick the lowest positive integer that is
# not currently being used by another source
if cat_id is None:
cat_id = utils.phase_center_catalog.generate_new_phase_center_id(
phase_center_catalog=self.phase_center_catalog, cat_id=cat_id
)

if self.phase_center_catalog is None:
# Initialize an empty dict to plug entries into
self.phase_center_catalog = {}
Expand All @@ -835,6 +827,14 @@ def _add_phase_center(
"but a different ID and parameters."
)

# We want to create a unique ID for each source, for use in indexing arrays.
# The logic below ensures that we pick the lowest positive integer that is
# not currently being used by another source
if cat_id is None or not force_update:
cat_id = utils.phase_center_catalog.generate_new_phase_center_id(
phase_center_catalog=self.phase_center_catalog, cat_id=cat_id
)

# If source is unique, begin creating a dictionary for it
self.phase_center_catalog[cat_id] = cat_entry
self.Nphase = len(self.phase_center_catalog)
Expand Down
1 change: 1 addition & 0 deletions tests/utils/test_phase_center_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def test_generate_new_phase_center_id_errs():
ps_cat_utils.generate_new_phase_center_id(cat_id=1, reserved_ids=[1, 2, 3])


@pytest.mark.filterwarnings("ignore:The uvw_array does not match the expected values")
def test_look_in_catalog_missing_entries():
casa_uvfits = UVData()
casa_uvfits.read(casa_tutorial_uvfits)
Expand Down
8 changes: 1 addition & 7 deletions tests/uvdata/test_ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,13 +712,7 @@ def test_ms_scannumber_multiphasecenter(tmp_path, multi_frame):
select_mask=miriad_uv.phase_center_id_array == cat_id[0],
)

with check_warnings(
UserWarning,
match=[
"The entry name NOISE is not unique",
"The provided name NOISE is already used",
],
):
with check_warnings(UserWarning, match="The entry name NOISE is not unique"):
miriad_uv.phase(
lon=ra_use,
lat=dec_use,
Expand Down
12 changes: 1 addition & 11 deletions tests/uvdata/test_uvdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,17 +1153,7 @@ def test_phasing(uv_phase_comp, unphase_first, use_ant_pos):
warning_str = ""
exp_warning = None
else:
warning_str = [
(
"The entry name UVCeti is not unique inside the phase center catalog, "
"adding anyways"
),
(
"The provided name UVCeti is already used but has different parameters."
" Adding another entry with the same name but a different ID and"
" parameters."
),
]
warning_str = "The entry name UVCeti is not unique inside the phase center"
exp_warning = UserWarning

if use_ant_pos:
Expand Down

0 comments on commit 80e36af

Please sign in to comment.