id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 499937876,MDU6SXNzdWU0OTk5Mzc4NzY=,3355,"Define aligning, broadcasting, merging, concatenating, combining in new glossary",2818208,closed,0,,,1,2019-09-29T16:16:45Z,2023-08-18T19:49:00Z,2023-08-18T19:49:00Z,CONTRIBUTOR,,,,"Over at https://github.com/pydata/xarray/pull/3352, we're working on a new page describing key Xarray terminology for https://github.com/pydata/xarray/issues/2410. Since it's already a big PR, and we may need to iterate on the definitions a few times, this issue is for extending the glossary once that PR is merged. Some terms are to add are: **aligning**, **broadcasting**, **merging**, **concatenating**, **combining**.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3355/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 499988033,MDU6SXNzdWU0OTk5ODgwMzM=,3356,Explain name matching rules for dimension and non-dimension coordinates,2818208,open,0,,,2,2019-09-29T23:29:19Z,2020-11-29T01:36:57Z,,CONTRIBUTOR,,,,"This arose as part of https://github.com/pydata/xarray/pull/3352. Xarray has important-to-understand name-matching rules for whether or not a coordinate array is a dimension coordinate or a non-dimension coordinate. To my knowledge, this is not in the documentation anywhere. This is what I had, but we decided to remove it since it was overly complicated for a list of key terms; maybe it'll be helpful going forward: > **Name matching rules:** Xarray follows simple but important-to-understand name matching rules for dimensions and coordinates. Let ``arr`` be an array with an existing dimension ``x`` and assigned new coordinates ``new_coords``. If ``new_coords`` is a list-like for e.g. ``[1, 2, 3]`` then they must be assigned a name that matches an existing dimension. For example, if ``arr.assign_coords({'x': [1, 2, 3]}).`` > > However, if ``new_coords`` is a one-dimensional ``DataArray``, then the rules are slightly more complex. In this case, if both ``new_coords``'s name and only dimension match any dimension name in ``arr.dims``, it is assigned as a dimension coordinate to ``arr``. If ``new_coords``'s name matches a name in ``arr.dims`` but its own dimension name does not, it is assigned as a non-dimension coordinate with name ``new_coords.dims[0]`` to ``arr``. Otherwise, an exception is raised.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3356/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 482452409,MDU6SXNzdWU0ODI0NTI0MDk=,3231,Dict-like argument support for assign_coords(),2818208,closed,0,,,3,2019-08-19T18:07:39Z,2019-09-28T20:44:08Z,2019-09-28T20:44:08Z,CONTRIBUTOR,,,,"Often the xarray API supports [either a `dict` or `kwargs`](https://github.com/pydata/xarray/blob/master/xarray/core/utils.py#L257), and it seems like this should be consistent as often as possible. With `assign_coords`, this works as expected: ```python >>> dims = [""x"", ""y""] >>> coords = {""fruit"": (""x"", [""apple"", ""banana""])} >>> arr = xr.DataArray([[1,2,3],[4,5,6]], dims=dims, coords=coords) >>> arr.assign_coords(color=(""x"", [""red"", ""yellow""])) array([[1, 2, 3], [4, 5, 6]]) Coordinates: fruit (x) >> arr.assign_coords({""color"": (""x"", [""red"", ""yellow""])}) *** TypeError: assign_coords() takes 1 positional argument but 2 were given ```","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3231/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 495920497,MDU6SXNzdWU0OTU5MjA0OTc=,3324,`sel` fails confusingly or silently when a dimension name matches an optional argument,2818208,open,0,,,10,2019-09-19T17:02:17Z,2019-09-20T21:23:18Z,,CONTRIBUTOR,,,,"Given that many Xarray methods accept `dict` or keyword arguments, this may effect other methods. That said, here is a minimal example with `sel`. #### Minimal example If I want to select based on a dimension named `method`, I cannot because Xarray thinks `method` is the `method` argument to `sel`: ```python >>> da1 = xr.DataArray(range(3), dims=['method'], coords={'method': range(3)}) >>> da1 array([0, 1, 2]) Coordinates: * method (method) int64 0 1 2 >>> da1.sel(method=0) ... TypeError: ``method`` must be a string ``` And if the `method` dimension has string labels, this fails silently: ```python >>> da2 = xr.DataArray(range(3), dims=['method'], coords={'method': list('abc')}) >>> da2.sel(method='a') array([0, 1, 2]) Coordinates: * method (method) ..."" to include in what will be committed) example-no-leap.nc foo.zarr/ manipulated-example-data.nc path/ nothing added to commit but untracked files present (use ""git add"" to track) ``` #### Expected Output I would expect no files to be created by `make html` in the `doc` directory. #### Problem Description It's not clear this will happen and may result in some people (me!) accidentally committing these files with `git commit -A`.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3227/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 484089737,MDU6SXNzdWU0ODQwODk3Mzc=,3240,assign_coords adds coordinates without a new dimension if the value is scalar,2818208,closed,0,,,5,2019-08-22T16:14:05Z,2019-08-26T08:16:37Z,2019-08-26T08:16:37Z,CONTRIBUTOR,,,,"### Problem `assign_corods` correctly disallows creating a new dimension when assigning `list`-like coords with a name that does not match an existing dimension. However, it does allow this operation if the value is scalar. ### MCVE Consider the following `DataArray`: ```python >>> coords = {""fruit"": (""x"", [""apple"", ""banana""])} >>> arr = xr.DataArray([[1, 2, 3], [4, 5, 6]], dims=(""x"", ""y""), coords=coords) >>> arr array([[1, 2, 3], [4, 5, 6]]) Coordinates: fruit (x) >> arr.assign_coords(color=(""x"", [""red"", ""yellow""])) array([[1, 2, 3], [4, 5, 6]]) Coordinates: fruit (x) >> arr.assign_coords(color=[""red"", ""yellow""]) ... ValueError: cannot add coordinates with new dimensions to a DataArray ``` The above fails because Xarray, in the absence of an explicit dimension, tries to assign the new coordinates to a `color` dimension which does not exist. So far so good. But why does _this_ work? ```python >>> arr = arr.assign_coords(color=""red"") >>> arr array([[1, 2, 3], [4, 5, 6]]) Coordinates: fruit (x) >> arr.coords Coordinates: fruit (x) Mapping from names matching dimensions and values given by (lists of) the names of existing coordinates or variables to set as new (multi-)index. This suggests that one can set a `DataArray` instance's coordinates by passing in a dimension and a list-like object of coordinates. #### MCVE ```python In [1]: import numpy as np In [2]: import xarray as xr In [3]: arr = xr.DataArray(data=np.ones((2, 3)), dims=['x', 'y']) In [4]: arr.dims Out[4]: ('x', 'y') In [5]: arr.set_index({'x': range(2)}) KeyError ... 144 for n in var_names: --> 145 var = variables[n] 146 if (current_index_variable is not None and 147 var.dims != current_index_variable.dims): KeyError: 0 ``` At first, I thought it might be because `coords` and `_coords` were not being set in this case: ```python In [18]: arr.coords Out[18]: Coordinates: *empty* In [19]: arr._coords Out[19]: OrderedDict() ``` but even if I set the coordinates first and then try to re-index, it fails: ```python In [20]: arr = xr.DataArray(data=np.ones((2, 3)), dims=['x', 'y'], coords={'x': range(2), 'y': range(3)}) In [21]: arr.set_index({'x': ['a', 'b', 'c']}) ... 144 for n in var_names: --> 145 var = variables[n] 146 if (current_index_variable is not None and 147 var.dims != current_index_variable.dims): ``` #### Expected Output I expect my MCVE to work based on the documentation. #### Problem Solution My guess is that the issue is Xarray is using the `merge_indexes` function ([see here](https://github.com/pydata/xarray/blob/master/xarray/core/dataarray.py#L1444)) from the `Dataset` module, and there is no concept of a `variable` in a `DataArray`.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3176/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue