You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistent behaviour with mean on masked array with and without dimensions given. #3841
I guess this is because when we say .mean(['x', 'y']), we do first mean along 'x', and then mean along 'y'.
If you follow this reasoning, then you can understand where the results come from.
Should the mean operation then just be implemented as the sum divided by volume, instead of doing mean on one dimension at a time?
I am not sure what exactly you mean by volume, but if volume is the number of elements that were summed up, then yeah, that's the behavior I would expect :)
Activity
nvaytet commentedon Feb 11, 2026
I guess this is because when we say
.mean(['x', 'y']), we do first mean along 'x', and then mean along 'y'.If you follow this reasoning, then you can understand where the results come from.
You get the same results from
numpy:However,
numpydiffers with us when you pass both axes in one go:which I guess is the desired behaviour?
So we should detect if the list of dims passed comprises all dims, and then just return the
.mean()instead of doing the dims one by one?jl-wynen commentedon Feb 12, 2026
That wouldn't be enough. E.g., given a 3d array and passing 2 dims, we would still differ from numpy.
damskii9992 commentedon Feb 12, 2026
And that is exactly my use-case. I'd like the mean to work like
.mean()on each value of the third dimension. So something like:nvaytet commentedon Feb 17, 2026
Should the mean operation then just be implemented as the sum divided by volume, instead of doing mean on one dimension at a time?
damskii9992 commentedon Feb 17, 2026
I am not sure what exactly you mean by volume, but if volume is the number of elements that were summed up, then yeah, that's the behavior I would expect :)
damskii9992 commentedon Jun 3, 2026
Any updates on this issue?