zonal_mean() and weighted_mean() should return the same type of object

Open Beginner friendly
#1,733 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
data

Research direction

Start by running the provided MCVE with UxDataArray.zonal_mean() and weighted_mean(), then locate both method implementations and compare how they construct their results. Confirm which return type the project intends for results without grid dimensions, and add or update coverage so both methods consistently return that type.

Written by the indexing model from the issue text.

Description

bug
Version

v2026.08.1

How did you install UXarray?

Source

What happened?

When calling UxDataArray.zonal_mean(), the output is an xarray.DataArray.
When calling UxDataArray.weighted_mean(), the output is a UxDataArray.

What did you expect to happen?

I expected these two functions to return the same type of object.

My guess is that both methods should return an xarray.DataArray because the result no longer contains any grid dimensions, and I've been thinking of "the data lives on the grid" as a core principle of UxDataArray and UxDataset objects. But, maybe that is wrong, and it should be UxDataArray for some reason?

Either way, I would definitely expect them to either both return xarray.DataArray objects or both return UxDataArray objects, because both functions produce results without any grid dimension.

Can you provide a MCVE to repoduce the bug?
import uxarray as ux
arr = ux.tutorial.open_dataset('quad-hexagon')['t2m']
arr.zonal_mean()  # this is an xarray.DataArray
arr.weighted_mean()  # this is a UxDataArray
Dominant language
Python
Stars
228
Forks
55
Avg merge
5d 1h
Merged PRs (30d)
14

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from UXARRAY/uxarray

All issues in UXARRAY/uxarray

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.