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/1151#issuecomment-603275549,https://api.github.com/repos/pydata/xarray/issues/1151,603275549,MDEyOklzc3VlQ29tbWVudDYwMzI3NTU0OQ==,2448579,2020-03-24T14:35:52Z,2020-03-24T14:35:52Z,MEMBER,"`xr.concat([a, b], dim=""x"")` was fixed by #3769
`xr.concat([a, b, c], dim=""x""` still gives an error
```
ValueError: 'y' not present in all datasets and coords='different'. Either add 'y' to datasets where it is missing or specify coords='minimal'.
```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,193294569
https://github.com/pydata/xarray/issues/1151#issuecomment-459770570,https://api.github.com/repos/pydata/xarray/issues/1151,459770570,MDEyOklzc3VlQ29tbWVudDQ1OTc3MDU3MA==,47244312,2019-02-01T15:58:21Z,2019-02-01T15:58:21Z,CONTRIBUTOR,This issue is still valid as of xarray 0.11.0,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,193294569
https://github.com/pydata/xarray/issues/1151#issuecomment-457162286,https://api.github.com/repos/pydata/xarray/issues/1151,457162286,MDEyOklzc3VlQ29tbWVudDQ1NzE2MjI4Ng==,26384082,2019-01-24T11:20:35Z,2019-01-24T11:20:35Z,NONE,"In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity
If this issue remains relevant, please comment here; otherwise it will be marked as closed automatically
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,193294569
https://github.com/pydata/xarray/issues/1151#issuecomment-269709113,https://api.github.com/repos/pydata/xarray/issues/1151,269709113,MDEyOklzc3VlQ29tbWVudDI2OTcwOTExMw==,1217238,2016-12-29T23:22:13Z,2016-12-29T23:22:13Z,MEMBER,"> Is there any helper function to facilitate this?
Yes, indeed. [`_maybe_promote`](https://github.com/pydata/xarray/blob/89a6732346542b234c0c655034c6e0ab49fecc56/xarray/core/common.py#L686) returns `dtype` and `fill_value` for inserting missing values, based on an original `dtype`. I guess it makes sense to start with calling one of the numpy utilities such as [`numpy.result_type`](https://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.result_type.html#numpy.result_type) for finding the common dtype to insert into `_maybe_promote`.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,193294569
https://github.com/pydata/xarray/issues/1151#issuecomment-269600582,https://api.github.com/repos/pydata/xarray/issues/1151,269600582,MDEyOklzc3VlQ29tbWVudDI2OTYwMDU4Mg==,6213168,2016-12-29T09:02:36Z,2016-12-29T09:05:48Z,MEMBER,"I just realised that xarray today already implements meaningful logic when concatenating between a and c in my example above - both on an existing dimension as well as on a new one. It's just a and b that don't work. I agree that defaulting to NaN would be a good option (regardless if the dimension is new or existing).
So to recap, when concatenating [a, b, c], where b does not have the y coord:
- if the dtype of the y coord in both a and c is float, numpy.float32, or numpy.float64, fill in with NaN
- if it's any datetime format, fill in with NaT
- if it's strings, fill in with empty string??
- in any other case, convert everything to object and fill in with None
Correct?
Is there any helper function to facilitate this?
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,193294569
https://github.com/pydata/xarray/issues/1151#issuecomment-269507204,https://api.github.com/repos/pydata/xarray/issues/1151,269507204,MDEyOklzc3VlQ29tbWVudDI2OTUwNzIwNA==,1217238,2016-12-28T17:07:31Z,2016-12-28T17:07:31Z,MEMBER,"@crusaderky Ah, I understand now. I agree that this makes sense for concatenating along an existing dimension (e.g., `xarray.concat([a, b], dim='x')` or `xarray.concat([a, c], dim='x')`) if the variables do not have the dimension to be concatenated. The existing logic to handle merging coordinates with possible dropping is the `merge_variables` function in `merge.py` (if `compat='minimal'`) -- note that none of the logic is specific to scalar coordinates.
For concatenating along a new dimension (e.g., `xarray.concat([a, b], dim='z')` or `xarray.concat([a, c], dim='z')`), I think we would want to default to a scalar coordinate of the appropriate missing value (e.g., `coords={'y': np.nan}`).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,193294569
https://github.com/pydata/xarray/issues/1151#issuecomment-269478770,https://api.github.com/repos/pydata/xarray/issues/1151,269478770,MDEyOklzc3VlQ29tbWVudDI2OTQ3ODc3MA==,6213168,2016-12-28T13:43:55Z,2016-12-28T13:43:55Z,MEMBER,"@shoyer the end goal is to replicate in concat() the same behaviour you already hav in \_\_add\_\_ and \_\_mul\_\_.
So take for example
```
a = xarray.DataArray([1, 2, 3], dims=['x'], coords={'y': 10})
b = xarray.DataArray([4, 5, 6], dims=['x'])
c = xarray.DataArray([7, 8, 9], dims=['x'], coords={'y': 20})
```
a+b -> y is propagated to the result (unambiguous)
a+c -> y is discarded (ambiguous)
I suppose I could look at how this happens in \_\_add\_\_ and move the logic up into broadcast() (which \_\_add\_\_ should already invoke)?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,193294569
https://github.com/pydata/xarray/issues/1151#issuecomment-269352243,https://api.github.com/repos/pydata/xarray/issues/1151,269352243,MDEyOklzc3VlQ29tbWVudDI2OTM1MjI0Mw==,1217238,2016-12-27T16:57:51Z,2016-12-27T16:57:51Z,MEMBER,"@crusaderky I don't understand the distinction between ambiguous/unambiguous coords -- can you clarify? Also, why treat scalar coordinates differently? Most xarray machinery doesn't special case arrays of a certain dimensionality.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,193294569
https://github.com/pydata/xarray/issues/1151#issuecomment-269089778,https://api.github.com/repos/pydata/xarray/issues/1151,269089778,MDEyOklzc3VlQ29tbWVudDI2OTA4OTc3OA==,6213168,2016-12-24T15:57:27Z,2016-12-24T15:57:27Z,MEMBER,"I updated the code and tested it in my project - it works fine.
Any suggestions before I start integrating it inside xarray.broadcast()?
```
def broadcast_scalar_coords(*args, exclude=()):
""""""Broadcast scalar coords whenever they're unambiguous,
and remove them when they are ambiguous.
This allows replicating the behaviour of addition
or moltiplication of xarrays in concatenation.
""""""
unambiguous = {}
ambiguous = set()
for arg in args:
for k, v in arg.coords.items():
if k in exclude:
continue
# non-scalar coords are automatically ambiguous
if v.shape == ():
if k not in ambiguous:
v = v.values.tolist()
if unambiguous.get(k, v) != v:
del unambiguous[k]
ambiguous.add(k)
else:
unambiguous[k] = v
else:
ambiguous.add(k)
unambiguous.pop(k, None)
args = tuple(arg.copy(deep=False) for arg in args)
for arg in args:
for k, v in unambiguous.items():
arg.coords[k] = v
for k in ambiguous:
if k in arg.coords and arg.coords[k].shape == ():
del arg.coords[k]
return args
```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,193294569
https://github.com/pydata/xarray/issues/1151#issuecomment-264912356,https://api.github.com/repos/pydata/xarray/issues/1151,264912356,MDEyOklzc3VlQ29tbWVudDI2NDkxMjM1Ng==,6213168,2016-12-05T17:05:34Z,2016-12-24T15:56:15Z,MEMBER,"I wrote down this.
1. should I simply add it to xarray.broadcast()?
2. can you spot any logical flaws?
3. suggestions for cleaner code?
[edit] removed obsolete code","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,193294569
https://github.com/pydata/xarray/issues/1151#issuecomment-264784694,https://api.github.com/repos/pydata/xarray/issues/1151,264784694,MDEyOklzc3VlQ29tbWVudDI2NDc4NDY5NA==,1217238,2016-12-05T07:27:54Z,2016-12-05T07:27:54Z,MEMBER,I agree -- we really should do an outer join of variables/coordinates in `concat`. I think here is another GitHub issue tracking this (this has certainly been raised before).,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,193294569