From ec40e004861dac9c1f6019cd6447a19c87f709d1 Mon Sep 17 00:00:00 2001 From: Sam Evans <47793072+Sevans711@users.noreply.github.com> Date: Mon, 10 Aug 2026 16:15:43 -0400 Subject: [PATCH] fix crash from getting healpix grid node_lat first (also adds regression test. See #1637) --- test/io/test_healpix.py | 14 ++++++++++++++ uxarray/grid/grid.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/test/io/test_healpix.py b/test/io/test_healpix.py index 947ccee79..84a359f97 100644 --- a/test/io/test_healpix.py +++ b/test/io/test_healpix.py @@ -280,3 +280,17 @@ def test_healpix_round_trip_consistency(tmp_path): # Validate grid dimensions are preserved assert reloaded_ugrid.n_face == original_grid.n_face assert reloaded_exodus.n_face == original_grid.n_face + +def test_healpix_grid_attr_access_order(): + """Ensure can access node_lon & node_lat attributes of healpix grid in any order. + (If problem turns out to exists with other attributes, can add them here later.) + Regression test for #1637. + """ + grid = ux.Grid.from_healpix(zoom=1) + grid.node_lon + grid.node_lat + + # just making sure this doesn't crash: + grid = ux.Grid.from_healpix(zoom=1) + grid.node_lat + grid.node_lon diff --git a/uxarray/grid/grid.py b/uxarray/grid/grid.py index 3c86890f2..89643feb7 100644 --- a/uxarray/grid/grid.py +++ b/uxarray/grid/grid.py @@ -1002,7 +1002,7 @@ def node_lat(self) -> xr.DataArray: """ if "node_lat" not in self._ds: if self.source_grid_spec == "HEALPix": - _populate_healpix_boundaries(self) + _populate_healpix_boundaries(self._ds) else: _set_desired_longitude_range(self) _populate_node_latlon(self)