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/1378#issuecomment-602795869,https://api.github.com/repos/pydata/xarray/issues/1378,602795869,MDEyOklzc3VlQ29tbWVudDYwMjc5NTg2OQ==,743508,2020-03-23T19:02:26Z,2020-03-23T19:02:26Z,CONTRIBUTOR,"Just wondering what the status of this is. I've been running into bugs trying to model symmetric distance matrices using the same dimension. Interestingly, it does work very well for selecting, e.g. if use `.sel(nodes=node_list)` on a square matrix i correctly get a square matrix subset 👍 But unfortunately a lot of other things seems to break, e.g. concatenating fails with `ValueError: axes don't match array` :( What would need to happen to make this work?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-528920519,https://api.github.com/repos/pydata/xarray/issues/1378,528920519,MDEyOklzc3VlQ29tbWVudDUyODkyMDUxOQ==,47244312,2019-09-06T16:22:12Z,2019-09-06T16:22:12Z,CONTRIBUTOR,"I'm not too fond of having multiple dimensions with the same name because, whenever you need to operate on one but not the other, you have little to no choice but revert to positional indexing. Consider also how many methods expect either **kwargs or a dict-like parameter with the dimension or variable names as the keys. I would not be surprised to find that many API design choices fall apart in the face of this use case. Also, having two _non positional_ (as it should always be in xarray!) dimensions with the same name only makes sense when modelling **symmetric N:N relationships**. Two good examples are covariance matrices and the weights for a Dijkstra algorithm. The problems start when the object represents an asymmetric relationship, e.g: - Cost (for the purpose of graph resolution, so time/money/other) of transportation via river, where going from A->B (downstream) is cheaper than going back from B->A (upstream) - Currency conversion, where ``EUR->USD`` is not identical to ``1/(USD->EUR)`` because of arbitrage and illiquidity - In financial Monte Carlo simulations, I had to deal with credit rating transition matrices which define the probability of a company to change its credit rating. In unfavourable market conditions, the chances of being downgraded from AAA to AA are higher than being promoted from AA to AAA. I could easily come up with many other cases. In case of asymmetric N:N relationships, it is highly desirable to share the same index across multiple dimensions with different names (that would typically convey the direction of the relationship, e.g. ""from"" and ""to""). What if, instead of allowing for duplicate dimensions, we allowed sharing an index across different dimensions? Something like ```python river_transport = Dataset( coords={ 'station': ['Kingston', 'Montreal'], 'station_from': ('station', ) 'station_to': ('station', ) }, data_vars={ cost=(('station_from', 'station_to'), [[0, 20], [15, 0]]), } } ``` or, for DataArrays: ```python river_transport = DataArray( [[0, 20], [15, 0]], dims=('station_from', 'station_to'), coords={ 'station': ['Kingston', 'Montreal'], 'station_from': ('station', ) 'station_to': ('station', ) }, } ``` Note how this syntax doesn't exist as of today: ```python 'station_from': ('station', ) 'station_to': ('station', ) ``` From an implementation point of view, I think it could be easily implemented by keeping track of a map of aliases and with some ``__geitem__`` magic. More effort would be needed to convince DataArrays to accept (and not accidentally drop) a coordinate whose dims don't match any of the data variable's. This design would not resolve the issue of compatibility with NetCDF though. I'd be surprised if the NetCDF designers never came across this - maybe it's a good idea to have a chat with them?","{""total_count"": 5, ""+1"": 5, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-405954547,https://api.github.com/repos/pydata/xarray/issues/1378,405954547,MDEyOklzc3VlQ29tbWVudDQwNTk1NDU0Nw==,1200058,2018-07-18T14:39:04Z,2018-07-18T14:39:04Z,NONE,Annotating distance matrices with xarray is not possible as well due to the duplicate dimension.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-376106248,https://api.github.com/repos/pydata/xarray/issues/1378,376106248,MDEyOklzc3VlQ29tbWVudDM3NjEwNjI0OA==,500246,2018-03-26T09:38:00Z,2018-03-26T09:38:00Z,CONTRIBUTOR,This also affects the `stack` method.,"{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-367153633,https://api.github.com/repos/pydata/xarray/issues/1378,367153633,MDEyOklzc3VlQ29tbWVudDM2NzE1MzYzMw==,500246,2018-02-20T23:10:13Z,2018-02-20T23:10:13Z,CONTRIBUTOR,"@jhamman Ok, good to hear it's not slated to be removed. I would love to work on this, I wish I had the time! I'll keep it in mind if I do find some spare time.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-367152237,https://api.github.com/repos/pydata/xarray/issues/1378,367152237,MDEyOklzc3VlQ29tbWVudDM2NzE1MjIzNw==,2443309,2018-02-20T23:03:54Z,2018-02-20T23:03:54Z,MEMBER,"@gerritholl - rereading this issue, I don't think we're particularly opposed to supporting duplicate dimensions. We do know there are things that don't work right now and that we don't have test coverage for operations that use duplicate dimensions. This is marked as a `help wanted` issue and I suspect that if someone like yourself, who has a use case for this functionality, were to want to work on this issue, we'd be happy to see it move forward. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-367147759,https://api.github.com/repos/pydata/xarray/issues/1378,367147759,MDEyOklzc3VlQ29tbWVudDM2NzE0Nzc1OQ==,500246,2018-02-20T22:46:27Z,2018-02-20T22:46:27Z,CONTRIBUTOR,"> I cannot see a use case in which repeated dims actually make sense. I use repeated dimensions to store a covariance matrix. The data variable containing the covariance matrix has 4 dimensions, of which the last 2 are repeated. For example, I have a data variable with dimensions (`channel`, `scanline`, `element`, `element`), storing an element-element covariance matrix for every scanline in satellite data. This is valid NetCDF and should be valid in xarray. It would be a significant problem for me if they became disallowed.","{""total_count"": 6, ""+1"": 6, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-295791392,https://api.github.com/repos/pydata/xarray/issues/1378,295791392,MDEyOklzc3VlQ29tbWVudDI5NTc5MTM5Mg==,1217238,2017-04-20T15:59:40Z,2017-04-20T15:59:40Z,MEMBER,"> I cannot see a use case in which repeated dims actually make sense. Agreed. I would have disallowed them entirely, but sometimes it's useful to allow loading variables with duplicate dimensions, even if the only valid operation you can do is de-duplicate them. Every routine that looks up dimensions by name should go through the [`get_axis_num` method](https://github.com/pydata/xarray/blob/ab4ffee919d4abe9f6c0cf6399a5827c38b9eb5d/xarray/core/common.py#L112). That would be a good place to add a check for uniqueness.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-295710929,https://api.github.com/repos/pydata/xarray/issues/1378,295710929,MDEyOklzc3VlQ29tbWVudDI5NTcxMDkyOQ==,10050469,2017-04-20T12:11:18Z,2017-04-20T12:11:18Z,MEMBER,"> In my case this situation originates from h5 files which indeed contains repeated dimensions Yes this happened to me too. First thing I did is converting the files to proper netcdf datasets...","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-295657656,https://api.github.com/repos/pydata/xarray/issues/1378,295657656,MDEyOklzc3VlQ29tbWVudDI5NTY1NzY1Ng==,668201,2017-04-20T09:50:19Z,2017-04-20T09:53:33Z,NONE,"I cannot see a use case in which repeated dims actually make sense. In my case this situation originates from h5 files which indeed contains repeated dimensions (`variables(dimensions): uint16 B0(phony_dim_0,phony_dim_0), ..., uint8 VAA(phony_dim_1,phony_dim_1)`), thus xarray is not to blame here. These are ""dummy"" dimensions, not associated with physical values. What we do to circumvent this problem is ""re-dimension"" all variables. Maybe a safe approach would be for open_dataset to raise a warning by default when encountering such variables, with possibly an option to perform automatic or custom dimension naming to avoid repeated dims. I also agree with @shoyer that failing loudly when operating on such DataArrays instead of providing confusing results would be an improvement.","{""total_count"": 5, ""+1"": 1, ""-1"": 4, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-295614924,https://api.github.com/repos/pydata/xarray/issues/1378,295614924,MDEyOklzc3VlQ29tbWVudDI5NTYxNDkyNA==,10050469,2017-04-20T07:47:18Z,2017-04-20T07:47:18Z,MEMBER,"I guess it would be good to document the expected behaviour with repeated dims somewhere? I.e. what should happen when doing: ``` a = xr.DataArray(eye(3), dims=['dim0', 'dim0']) a.mean(dim='dim0') ``` ? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-295593740,https://api.github.com/repos/pydata/xarray/issues/1378,295593740,MDEyOklzc3VlQ29tbWVudDI5NTU5Mzc0MA==,668201,2017-04-20T06:11:02Z,2017-04-20T06:11:02Z,NONE,"Right, also positional indexing works unexpectedly in this case, though I understand it's tricky and should probably be discouraged: ```python A[0,:] # returns A A[:,0] # returns A.isel(dim0=0) ``` ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-295431292,https://api.github.com/repos/pydata/xarray/issues/1378,295431292,MDEyOklzc3VlQ29tbWVudDI5NTQzMTI5Mg==,1217238,2017-04-19T20:39:33Z,2017-04-19T20:40:08Z,MEMBER,"Indeed, we don't have very good test coverage for operations with repeated dimensions. Fixes would certainly be appreciated, though they might be somewhat tricky. Even failing loudly with `ValueError: repeated dimensions not yet supported` would be an improvement over the current state.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855 https://github.com/pydata/xarray/issues/1378#issuecomment-295192317,https://api.github.com/repos/pydata/xarray/issues/1378,295192317,MDEyOklzc3VlQ29tbWVudDI5NTE5MjMxNw==,10050469,2017-04-19T09:46:37Z,2017-04-19T09:46:37Z,MEMBER,"Yes, also happening on latest master. I suspect there are several other things which won't work properly (or at least unexpectedly) when having repeated dims...","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,222676855