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/6196#issuecomment-1450036767,https://api.github.com/repos/pydata/xarray/issues/6196,1450036767,IC_kwDOAMm_X85Wbc4f,32069530,2023-03-01T12:09:21Z,2023-03-01T12:09:40Z,NONE,"Hello @TomNicholas ,
Reopening this issue 1 year later ! To answer your last question, singleton dimension seems to have, indeed, a unique behavior since they are reattached systematically to other coordinates (even if they naturally do not share any dimension with other coordinates).
These singleton dimensions introduce some strange behavior. This is another example:
```
a = xr.DataArray(np.random.rand(2,3,2), dims=('x','y','z'), coords={'x':[1,2], 'y':[3,4,5],'z':['0','1']})
b = xr.DataArray(np.random.rand(2,3,2), dims=('x','y','z'), coords={'x':[1,2], 'y':[3,4,5],'z':['0','1']})
res1 = a.sel(z='0')/b
res2 = a.sel(z='0').expand_dims('z')/b
```
res1 and res2 do not have the same size on dimension ""z"". In res1, dimension ""z"" is not considered anymore as a dimension at all !
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1115166039
https://github.com/pydata/xarray/issues/6196#issuecomment-1026774266,https://api.github.com/repos/pydata/xarray/issues/6196,1026774266,IC_kwDOAMm_X849M1T6,32069530,2022-02-01T12:07:51Z,2022-02-01T12:07:51Z,NONE,"Thanks for the enlightening.
Actually, this coordinates dependency with singleton dimension caused me a problem when using the to_netcdf() function. No problem playing whith the xr.Dataset but I get some error when trying to write on disk using to_netcdf().
For now, I wasn't able to reproduce a minimalist example because the error disappears with minimalist example. I wasn't able to find the fundamental difference between the dataset causing the error and the minimalist one. Printing them are exactly the same. I have to do deeper inspection.
Concerning the philosophy of what a coordinate should be: For me the ""label"" idea is understandable at a dataset level. A singleton dimension become a (shared) ""label' for the whole dataset. This is ok for me. However, I do not understand why it should also be a ""label"" of the other coordinates of the dataset. A singleton dimension should not be ""more important"" than the other (not singleton) dimensions. Why the singleton dimension should become a ""label"" of another dimension while the other dimensions are not. This do not seem logical to me.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1115166039