From 2b3a0dc40e232cb956f5a1ac0da45c16a1ca7c9e Mon Sep 17 00:00:00 2001 From: Rui Xue Date: Thu, 26 Mar 2026 12:29:06 -0500 Subject: [PATCH] Use `np.atleast_1d` for `worldreplace` coordinates and remove the associated test workaround. --- src/xradio/image/_util/_casacore/xds_to_casacore.py | 5 +++-- tests/unit/image/test_image.py | 5 ----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/xradio/image/_util/_casacore/xds_to_casacore.py b/src/xradio/image/_util/_casacore/xds_to_casacore.py index 48d7e741..82bc9abf 100644 --- a/src/xradio/image/_util/_casacore/xds_to_casacore.py +++ b/src/xradio/image/_util/_casacore/xds_to_casacore.py @@ -214,8 +214,9 @@ def _coord_dict_from_xds(xds: xr.Dataset) -> dict: coord["worldmap2"] = np.array([3], dtype=np.int32) # this probbably needs some verification coord["worldreplace0"] = [0.0, 0.0] - coord["worldreplace1"] = np.array(coord["stokes1"]["crval"]) - coord["worldreplace2"] = np.array(coord["spectral2"]["wcs"]["crval"]) + coord["worldreplace1"] = np.atleast_1d(coord["stokes1"]["crval"]) + coord["worldreplace2"] = np.atleast_1d(coord["spectral2"]["wcs"]["crval"]) + return coord diff --git a/tests/unit/image/test_image.py b/tests/unit/image/test_image.py index 6d7877f6..56b57032 100644 --- a/tests/unit/image/test_image.py +++ b/tests/unit/image/test_image.py @@ -475,11 +475,6 @@ def test_metadata(self): # by casacore on the fly, so we cannot easily compare them, # and really comes down to comparing the values of c used in # the computations (eg, if c is in m/s or km/s) - # it appears that 'worldreplace2' is not correctly recorded or retrieved - # by casatools, with empty np.array returned instead. - c2["coordinates"]["worldreplace2"] = np.array( - [c2["coordinates"]["spectral2"]["wcs"]["crval"]] - ) assert_attrs_dicts_equal( c2, c1,