Repository navigation
Open
Labels
scalabilityRelated to scalability & performance efforts
Description
Proposed new feature or change:
There are a number of sites in the codebase that call .values erroneously, but most of the sites are legitimate. I'm planning on going case-by-case systematically to try to clean them up.
From Claude:
PROBLEM SITES (28)
| File | Line | Should be | Expression | Notes |
|---|---|---|---|---|
| uxarray/core/aggregation.py | 106 | dask.Array (lazy) |
data = uxda.values |
dask branch routes here behind TODO:; _apply_*_dask is a pass stub (known gap) |
| uxarray/core/aggregation.py | 174 | dask.Array (lazy) |
data = uxda.values |
dask branch routes here behind TODO:; _apply_*_dask is a pass stub (known gap) |
| uxarray/core/dataarray.py | 248 | int (xarray metadata) |
if self.values.ndim > 1: |
.values.ndim full compute to read rank; use self.ndim |
| uxarray/core/dataarray.py | 255 | int (xarray metadata) |
if self.values.size == self.uxgrid.n_face: |
.values.size full compute to read size; use self.size |
| uxarray/core/dataarray.py | 292 | int (xarray metadata) |
elif self.values.size == self.uxgrid.n_node: |
.values.size full compute to read size; use self.size |
| uxarray/core/dataarray.py | 294 | int (xarray metadata) |
f"Data Variable with size {self.values.size} does not match the number of f... |
full compute just to format an error-message f-string; use self.size |
| uxarray/core/dataarray.py | 298 | int (xarray metadata) |
elif self.values.size == self.uxgrid.n_edge: |
.values.size full compute to read size; use self.size |
| uxarray/core/dataarray.py | 300 | int (xarray metadata) |
f"Data Variable with size {self.values.size} does not match the number of f... |
full compute just to format an error-message f-string; use self.size |
| uxarray/core/dataarray.py | 306 | int (xarray metadata) |
f"Data Variable with size {self.values.size} does not match the number of f... |
full compute just to format an error-message f-string; use self.size |
| uxarray/core/dataarray.py | 342 | int (xarray metadata) |
if self.values.ndim > 1: |
.values.ndim full compute to read rank; use self.ndim |
| uxarray/core/dataarray.py | 612 | int (xarray metadata) |
if self.values.shape[-1] == self.uxgrid.n_face: |
.values.shape[-1] full compute to read shape; use self.shape[-1] |
| uxarray/core/dataarray.py | 616 | dask.Array (lazy) |
integral = np.einsum("i,...i", face_areas, self.values) |
np.einsum over whole field to yield a scalar; xr.dot/(self*areas).sum() stays lazy |
| uxarray/core/dataarray.py | 618 | int (xarray metadata) |
elif self.values.shape[-1] == self.uxgrid.n_node: |
.values.shape[-1] full compute to read shape; use self.shape[-1] |
| uxarray/core/dataarray.py | 621 | int (xarray metadata) |
elif self.values.shape[-1] == self.uxgrid.n_edge: |
.values.shape[-1] full compute to read shape; use self.shape[-1] |
| uxarray/core/dataarray.py | 629 | int (xarray metadata) |
f"but received {self.values.shape[-1]}" |
full compute to format an error-message f-string; use self.shape[-1] |
| uxarray/core/dataarray.py | 2181 | dask.Array (lazy) |
data = np.array(self.values) |
np.array(self.values) computes+copies entire array for a pure dim rename; use self.data |
| uxarray/core/dataset.py | 719 | dask.Array (lazy) |
data = np.array(self[var].values) |
same to_dual defect as dataarray.py:2181, per-variable in a loop; use .data |
| uxarray/cross_sections/dataarray_accessor.py | 123 | dask.Array (lazy) |
arr = np.moveaxis(self.uxda.compute().values, face_axis, -1) |
.compute().values materializes whole field; _fill_numba is a pure gather of ~steps columns |
| uxarray/grid/grid.py | 1582 | dask.Array (lazy) |
self.edge_face_connectivity.values |
full (n_edge,2) compute for a np.where dask does lazily; use .data |
| uxarray/grid/grid.py | 1963 | dask.Array (lazy) |
return np.sum(self.face_areas.values) |
np.sum(face_areas.values) materializes all n_face for one float; use .sum() |
| uxarray/grid/slice.py | 38 | dask.Array (lazy) |
face_indices = np.unique(grid.node_face_connectivity.values[indices].ravel()) |
.values[indices] computes whole node_face_connectivity; use .isel(n_node=indices) |
| uxarray/grid/slice.py | 68 | dask.Array (lazy) |
face_indices = np.unique(grid.edge_face_connectivity.values[indices].ravel()) |
.values[indices] computes whole edge_face_connectivity; use .isel(n_edge=indices) |
| uxarray/grid/slice.py | 106 | dask.Array (lazy) |
node_indices = np.unique(grid.face_node_connectivity.values[face_indices].r... |
.values[face_indices] computes whole face_node_connectivity; use .isel(n_face=...) |
| uxarray/grid/slice.py | 116 | dask.Array (lazy) |
grid.face_edge_connectivity.values[face_indices].ravel() |
.values[face_indices] computes whole face_edge_connectivity; use .isel(n_face=...) |
| uxarray/grid/slice.py | 172 | dask.Array (lazy) |
np.vectorize(map_fn, otypes=[INT_DTYPE])(ds[conn_name].values), |
np.vectorize(...)(ds[conn].values) strips chunking from output grid; apply_ufunc/map_blocks |
| uxarray/io/_scrip.py | 28 | dask.Array (lazy) |
values = data_array.values |
_values_in_degrees eagerly loads freshly-opened grid; defeats deliberately-lazy grid_center_lat_lon |
| uxarray/plot/matplotlib.py | 205 | dask.Array (lazy) |
flat_vals[mask_has_face] = data.values[first_face[mask_has_face]] |
materializes entire n_face field before raster subset; use .isel(n_face=<unique valid>) |
| uxarray/remap/apply_weights.py | 90 | dask.Array (lazy) |
remapped_values = weights_obj._apply(np.asarray(da_t.values)) |
sparse weights @ data materializes full field; blockwise over leading dims -> apply_ufunc(dask='parallelized') |
REPLACE WITH `.data` (8)
| File | Line | Should be | Expression | Notes |
|---|---|---|---|---|
| uxarray/core/dataarray.py | 1653 | dask.Array (lazy) |
curl_values = grad_v_zonal.values - grad_u_meridional.values |
elementwise subtract; dask handles lazily |
| uxarray/grid/grid.py | 1235 | dask.Array (lazy) |
face_node_connectivity_1d = self._ds["face_node_connectivity"].values |
np.expand_dims works on dask; only reached for degenerate ndim==1 |
| uxarray/grid/grid.py | 2484 | dask.Array (lazy) |
self.face_lon.values, self.face_lat.values, dual_node_face_conn |
_read_topology only rewraps in xr.DataArray; dask passes through (x2: face_lon/face_lat) |
| uxarray/io/_geos.py | 15 | dask.Array (lazy) |
node_lon = in_ds["corner_lons"].values.ravel() |
.values.ravel() on just-opened dataset -> xr.DataArray; use .data.ravel() |
| uxarray/io/_geos.py | 16 | dask.Array (lazy) |
node_lat = in_ds["corner_lats"].values.ravel() |
.values.ravel() on just-opened dataset -> xr.DataArray; use .data.ravel() |
| uxarray/io/_geos.py | 27 | dask.Array (lazy) |
face_lon = in_ds["lons"].values.ravel() |
same; ~12.5M elements/array at c1440 |
| uxarray/io/_geos.py | 28 | dask.Array (lazy) |
face_lat = in_ds["lats"].values.ravel() |
same; ~12.5M elements/array at c1440 |
| uxarray/remap/structured.py | 168 | dask.Array (lazy) |
np.asarray(da.values).reshape(shape), |
collapses an otherwise-lazy nearest-neighbor pipeline; .data.reshape (may need rechunk) |
DEAD CODE (9)
| File | Line | Should be | Expression | Notes |
|---|---|---|---|---|
| uxarray/core/gradient.py | 151 | n/a (dead code) |
# [uxgrid.node_x.values, uxgrid.node_y.values, uxgrid.node_z.values] |
inside a commented-out _node_centered block |
| uxarray/core/gradient.py | 153 | n/a (dead code) |
# node_lat = uxgrid.node_lat.values |
inside a commented-out _node_centered block |
| uxarray/core/gradient.py | 154 | n/a (dead code) |
# node_lon = uxgrid.node_lon.values |
inside a commented-out _node_centered block |
| uxarray/core/gradient.py | 174 | n/a (dead code) |
# data.values, |
inside a commented-out _node_centered block |
| uxarray/core/gradient.py | 179 | n/a (dead code) |
# uxgrid.node_edge_connectivity.values, |
inside a commented-out _node_centered block |
| uxarray/core/gradient.py | 180 | n/a (dead code) |
# uxgrid.edge_face_connectivity.values, |
inside a commented-out _node_centered block |
| uxarray/core/gradient.py | 181 | n/a (dead code) |
# uxgrid.edge_node_connectivity.values, |
inside a commented-out _node_centered block |
| uxarray/core/gradient.py | 182 | n/a (dead code) |
# uxgrid.node_face_connectivity.values, |
inside a commented-out _node_centered block |
| uxarray/grid/grid.py | 2569 | n/a (dead code) |
lat, self.edge_node_z.values, self.n_edge |
self.edge_node_z does not exist -> AttributeError on default path (see Task below) |
With the first pass, I'm focusing on getting these fixed in-context, but most likely there are deeper issues being hinted at here, so that will require a deeper look at how the heirarchy of delegation works.
Metadata
Metadata
Assignees
Labels
scalabilityRelated to scalability & performance efforts
Type
Fields
Priority
High
Projects
- StatusShow more project fields🏗 In progress
Activity
erogluorhan commentedon Jul 17, 2026
Thanks a lot for taking this one; this is very important for chunked-array compatibility
Sevans711 commentedon Jul 20, 2026
Flagging as possibly related: #1558 includes behavior like: arr.ndim changes after calling .values, for 2D+ dask arr coming from result of .subset(). I noticed this occurs at
.valuesline 528 in uxarray/plot/accessor.py, inside UxDataArrayPlotAccessor'sdef points(...):verts = {"lon": lon, "lat": lat, "z": self._uxda.values}. E.g., addprint('before:', self._uxda.ndim)before that line andprint('after:', self._uxda.ndim)after that line, using the example discussed in that issue, and you would see "before: 2" and "after: 3".Although, if the main focus here is just efficiency, then maybe that bug isn't relevant; I only noticed it for data that becomes size 0 after subsetting.
cmdupuis3 commentedon Jul 24, 2026
@Sevans711 We can make this a catch-all issue, the current PR is intended to be a quick and easy thing, but I'm going to make some deeper passes through the code to see if I can quash more. We'll just add more PRs as is reasonable.
rajeeja commentedon Jul 24, 2026
This has been on my to-do list for long. Thanks for picking this up. I'll take a detailed look and get back to you soon.