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 497416198,MDExOlB1bGxSZXF1ZXN0MzIwNTUxODg0,3336,Provide better error message when dimension name matches argument,2818208,open,0,,,7,2019-09-24T02:16:05Z,2023-12-02T02:53:11Z,,CONTRIBUTOR,,0,pydata/xarray/pulls/3336,"WIP PR for https://github.com/pydata/xarray/issues/3324. Since `either_dict_or_kwargs` is called 57 times, I don't want to modify every function call without a preliminary review. My main question is if using `locals()` at the top of each function is considered acceptable. Of course, if `locals()` is called _after_ some local variables are created, this code could raise an error when no conflict exists. But explicitly passing in the function argument names in all 57 functions seems brittle. I'd appreciate any thoughts on the PR before I modify all the functions and write some tests.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3336/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 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 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)