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/4821#issuecomment-860244940,https://api.github.com/repos/pydata/xarray/issues/4821,860244940,MDEyOklzc3VlQ29tbWVudDg2MDI0NDk0MA==,5635139,2021-06-13T17:28:13Z,2021-06-13T17:28:13Z,MEMBER,"Yes, we want to replace that test with your test — either in the same test function or a new test function.
Though it maybe it should still be a `KeyError`, I think probably it should be. But feel free to submit the PR and it's easiest to review there.
Thanks!","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787847449
https://github.com/pydata/xarray/issues/4821#issuecomment-859802038,https://api.github.com/repos/pydata/xarray/issues/4821,859802038,MDEyOklzc3VlQ29tbWVudDg1OTgwMjAzOA==,14808389,2021-06-11T19:45:26Z,2021-06-11T19:45:26Z,MEMBER,"here's an example:
```python
In [2]: xr.Dataset({""a"": ([(""a"", ""b"")], [1])})
Out[2]:
Dimensions: (('a', 'b'): 1)
Dimensions without coordinates: ('a', 'b')
Data variables:
a (('a', 'b')) int64 1
```","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787847449
https://github.com/pydata/xarray/issues/4821#issuecomment-859690070,https://api.github.com/repos/pydata/xarray/issues/4821,859690070,MDEyOklzc3VlQ29tbWVudDg1OTY5MDA3MA==,5635139,2021-06-11T16:14:15Z,2021-06-11T16:14:15Z,MEMBER,"> If you allow explicitly tuple, doesn't it mean I need to edit this part
Yes!
> (I find it a little bit weird to give dimensions in list, no ? I thought that generally tuples were more adapted to provide dims)
Yes, I feel similarly. For one `xr.Dataset(dict(var=(('a','b'), np.random.rand(3))))` is an error, rather than a one-dimensioned dataset with a single dim called `('a','b')`. But OTOH I can very much empathize with accepting any Hashable for dim names most functions, which includes tuples. So I am fine formalizing this (apart from the constructor).
> Can you tell me which test-case I can implement to fulfill all the requirements needed ? I can't think of test cases that I can implement except the one suggested first, and that one passes with the first modification
How about a test that checks the example above suggests a list, rather than raising a vanilla `KeyError`?
Cheers @thomashirtz ","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787847449
https://github.com/pydata/xarray/issues/4821#issuecomment-855287336,https://api.github.com/repos/pydata/xarray/issues/4821,855287336,MDEyOklzc3VlQ29tbWVudDg1NTI4NzMzNg==,5635139,2021-06-05T19:49:24Z,2021-06-05T19:51:19Z,MEMBER,"Great, agree @dcherian . So maybe we:
- Check whether the dim exists (there could be a dim with tuple), which is already done in 1371 below
- If it doesn't exist, then check whether it's a string before passing it to `_get_virtual_variable` below. If it's a tuple, that message can suggest passing it as a list.
- Or we do the check _in_ `_get_virtual_variable`?
```python
1366 def _construct_dataarray(self, name: Hashable) -> ""DataArray"":
1367 """"""Construct a DataArray by indexing this dataset""""""
1368 from .dataarray import DataArray
1369
1370 try:
1371 variable = self._variables[name]
1372 except KeyError:
-> 1373 _, name, variable = _get_virtual_variable(
1374 self._variables, name, self._level_coords, self.dims
1375 )
```
@thomashirtz changing the labels back! Thanks in advance!","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787847449
https://github.com/pydata/xarray/issues/4821#issuecomment-855286432,https://api.github.com/repos/pydata/xarray/issues/4821,855286432,MDEyOklzc3VlQ29tbWVudDg1NTI4NjQzMg==,2448579,2021-06-05T19:41:34Z,2021-06-05T19:41:34Z,MEMBER,"I think 2 and 3 become really confusing with `swap_dims` (for e.g.) So my vote is for 1. In all three cases, the solution to this issue is to suggest passing lists in the error message?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787847449
https://github.com/pydata/xarray/issues/4821#issuecomment-855276547,https://api.github.com/repos/pydata/xarray/issues/4821,855276547,MDEyOklzc3VlQ29tbWVudDg1NTI3NjU0Nw==,5635139,2021-06-05T18:16:38Z,2021-06-05T18:16:38Z,MEMBER,"Any thoughts from others on what we should do, of the three options above? CC @pydata/xarray ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787847449
https://github.com/pydata/xarray/issues/4821#issuecomment-766234825,https://api.github.com/repos/pydata/xarray/issues/4821,766234825,MDEyOklzc3VlQ29tbWVudDc2NjIzNDgyNQ==,14808389,2021-01-23T23:50:40Z,2021-01-23T23:50:53Z,MEMBER,"All of these options are breaking changes so we would probably have to go through a deprecation cycle. 1 might be the most consistent and least confusing, but if we want to keep the current behavior we could require wrapping a `tuple` in another sequence to access dimension names.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787847449
https://github.com/pydata/xarray/issues/4821#issuecomment-766166088,https://api.github.com/repos/pydata/xarray/issues/4821,766166088,MDEyOklzc3VlQ29tbWVudDc2NjE2NjA4OA==,5635139,2021-01-23T19:26:54Z,2021-01-23T19:26:54Z,MEMBER,"I would propose we either:
- Explicitly allow tuples as dimension and variable names. This is probably the most mypy-compatible, since we use `Hashable` in lots of places
- Force dimension names to be strings, but allow variable names to be `Hashable`. This might be the most practical.
- Disallow tuples for dimension names, but otherwise allow `Hashable`. Then tuples work the same as lists when supplied as arguments.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787847449
https://github.com/pydata/xarray/issues/4821#issuecomment-762710092,https://api.github.com/repos/pydata/xarray/issues/4821,762710092,MDEyOklzc3VlQ29tbWVudDc2MjcxMDA5Mg==,10194086,2021-01-19T09:17:07Z,2021-01-19T09:17:07Z,MEMBER,"Ah yes you are right... However, we are not consistent with this, e.g. that works for reductions `air.mean((""lat"", ""lon""))`","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787847449
https://github.com/pydata/xarray/issues/4821#issuecomment-762523614,https://api.github.com/repos/pydata/xarray/issues/4821,762523614,MDEyOklzc3VlQ29tbWVudDc2MjUyMzYxNA==,14808389,2021-01-19T00:11:25Z,2021-01-19T00:12:04Z,MEMBER,"I think it's the way it is because `tuple` is hashable, so it can be used as a name:
```python
ds = xr.Dataset({(""a"", 0): (""x"", [1, 0])})
ds.sortby((""a"", 0))
```
not sure if there's a particular use case where supporting this is crucial","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787847449
https://github.com/pydata/xarray/issues/4821#issuecomment-762521955,https://api.github.com/repos/pydata/xarray/issues/4821,762521955,MDEyOklzc3VlQ29tbWVudDc2MjUyMTk1NQ==,10194086,2021-01-19T00:04:30Z,2021-01-19T00:04:30Z,MEMBER,"Yes, I am marking that as a bug. The problem is here:
https://github.com/pydata/xarray/blob/295606707a0464cd13727794a979f5b709cd92a1/xarray/core/dataset.py#L5612-L5613
as the tuple is not a list it ends up as `[('x', 'y')]`. That should probably be
```python
if isinstance(variables, str):
variables = [variables]
```
or
```python
if not isinstance(variables, (list, tuple)):
variables = [variables]
```
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787847449