Open xabipedru opened 1 year ago
Good point, that can be surprising. I think a warning could be added.
if not set(self.obj.dims) & set(self.weights.dims):
warnings.warn("")
However, I wonder if that would be too noisy, e.g. if there is a scalar on the Dataset:
xr.Dataset({"test_array": test_array, "scalar": 1}).weighted(weights2).mean()
(could potentially skip scalars in the check).
Edit:
may not be the right place, as it checks it on the Dataset level (and not on the DataArray level).
What happened?
dataarray.weighted(weights).mean() performs an unweighted mean if dimensions of weights and to-be-weighted-array differ. That is ok, but a warning message informing of it would be very helpful, as currently the mean is just performed and the user may assume that a weighted mean happenned.
What did you expect to happen?
I would expect to get a warning when performing the mean, knowing that it is not using the weights that it got assigned.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
No response
Anything else we need to know?
No response
Environment