html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/7748#issuecomment-1506592074,https://api.github.com/repos/pydata/xarray/issues/7748,1506592074,IC_kwDOAMm_X85ZzMVK,4441338,2023-04-13T08:51:47Z,2023-04-13T08:51:47Z,NONE,"My user story is that I had up to some point a DataArray with index 'a', at some point code changed and I used as index 'b', but some code was still operating on 'a'; and I expected that code to error on accessing 'a'.
If I do np.diff(x,axis=(some non-existent axis)), numpy errors.
I might be generalizing, please correct me if I'm wrong, but afaik broadcasting happens in operations with 2 or more arrays, and the resulting dimensions are the union of the dimensions of each input array; the dimensions operated on are always at least in one of the involved arrays.
Broadcasting does not happen if the arrays have the same shape, as it is for the diff operation.
So by following the same logic, when using an unary operator on a Dataset, an error should be thrown if none of the contained variables have the requested dimension.
Since xarray allows scalar-sized dimensions (where the index shape is () ), those could be used to keep current behavior.
I read the linked issue. imho, the operation on a DataArray should error if the dimension is not there; on a Dataset the operation should be applied to each DataArray that contains the dimension, and if there are none, an error should be thrown. i.e. (set of dimensions allowed as arguments to operators on a set of containers) = ( union of the dimensions in each container).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1664193419
https://github.com/pydata/xarray/issues/7748#issuecomment-1506550069,https://api.github.com/repos/pydata/xarray/issues/7748,1506550069,IC_kwDOAMm_X85ZzCE1,43316012,2023-04-13T08:20:24Z,2023-04-13T08:20:24Z,COLLABORATOR,See also somewhat related discussion here https://github.com/pydata/xarray/issues/6749,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1664193419
https://github.com/pydata/xarray/issues/7748#issuecomment-1506544631,https://api.github.com/repos/pydata/xarray/issues/7748,1506544631,IC_kwDOAMm_X85ZzAv3,43316012,2023-04-13T08:16:11Z,2023-04-13T08:16:11Z,COLLABORATOR,"Not sure what the correct way would be.
If you consider that `d f(x) / d y = 0`, maybe all zeros could be considered correct as well.
The same result can be obtained if one considers that the array might be broadcast to the y-dim.
Also we have to check that happens in Datasets if one of the variables does not contain this dimension, do we raise an error as well?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1664193419