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/pull/1496#issuecomment-321002750,https://api.github.com/repos/pydata/xarray/issues/1496,321002750,MDEyOklzc3VlQ29tbWVudDMyMTAwMjc1MA==,2443309,2017-08-08T16:04:38Z,2017-08-08T16:04:38Z,MEMBER,LGTM. Merge when ready.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,246502828
https://github.com/pydata/xarray/pull/1496#issuecomment-320755613,https://api.github.com/repos/pydata/xarray/issues/1496,320755613,MDEyOklzc3VlQ29tbWVudDMyMDc1NTYxMw==,6200806,2017-08-07T19:19:56Z,2017-08-07T19:19:56Z,CONTRIBUTOR,">any final comments
@jhamman none; thanks @shoyer for including the function-version of where","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,246502828
https://github.com/pydata/xarray/pull/1496#issuecomment-319477348,https://api.github.com/repos/pydata/xarray/issues/1496,319477348,MDEyOklzc3VlQ29tbWVudDMxOTQ3NzM0OA==,1217238,2017-08-01T19:50:52Z,2017-08-01T19:50:52Z,MEMBER,"> I had meant: 'exact' includes other having a subset of dimensions, where the missing dimensions are easy to broadcast out
Yes, that works :). Exact only requires that common dimensions have the same lengths/labels, not that all arguments have the same dimensions.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,246502828
https://github.com/pydata/xarray/pull/1496#issuecomment-319471941,https://api.github.com/repos/pydata/xarray/issues/1496,319471941,MDEyOklzc3VlQ29tbWVudDMxOTQ3MTk0MQ==,5635139,2017-08-01T19:28:15Z,2017-08-01T19:28:15Z,MEMBER,"Not a clear comment. I had meant for this to work, which it does:
```python
In [1]: import xarray as xr
In [2]: import numpy as np
In [3]: a = xr.DataArray(np.random.rand(3,4), dims=['x','y'])
In [4]: b = xr.DataArray(np.random.rand(3,1), dims=['x','y'])
In [5]: a+b.squeeze()
Out[5]:
array([[ 1.394345, 0.916842, 0.806284, 1.604707],
[ 1.011313, 0.736347, 0.677679, 0.970856],
[ 0.477433, 0.825672, 1.014959, 0.495829]])
Dimensions without coordinates: x, y
In [6]: a.where(a>0.5, b.squeeze())
Out[6]:
array([[ 0.676462, 0.717883, 0.717883, 0.886823],
[ 0.568829, 0.442484, 0.442484, 0.528372],
[ 0.100403, 0.725269, 0.914556, 0.100403]])
Dimensions without coordinates: x, y
```
I had meant: `'exact'` includes `other` having a _subset_ of dimensions, where the missing dimensions are easy to broadcast out","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,246502828
https://github.com/pydata/xarray/pull/1496#issuecomment-319426805,https://api.github.com/repos/pydata/xarray/issues/1496,319426805,MDEyOklzc3VlQ29tbWVudDMxOTQyNjgwNQ==,1217238,2017-08-01T16:40:01Z,2017-08-01T16:40:01Z,MEMBER,"> Does exact allow a scalar on a dimension? That's then simple and unambiguous to broadcast.
I'm not quite sure what you mean by this, can you explain?
I think the answer is probably no (but perhaps we could change that)","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,246502828
https://github.com/pydata/xarray/pull/1496#issuecomment-319423470,https://api.github.com/repos/pydata/xarray/issues/1496,319423470,MDEyOklzc3VlQ29tbWVudDMxOTQyMzQ3MA==,5635139,2017-08-01T16:27:41Z,2017-08-01T16:27:41Z,MEMBER,"This is excellent! Thank you @shoyer .
I agree with forcing exact alignment for the 3 arg version. Does `exact` allow a scalar on a dimension? That's then simple and unambiguous to broadcast.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,246502828
https://github.com/pydata/xarray/pull/1496#issuecomment-318959273,https://api.github.com/repos/pydata/xarray/issues/1496,318959273,MDEyOklzc3VlQ29tbWVudDMxODk1OTI3Mw==,1217238,2017-07-31T03:34:45Z,2017-07-31T03:34:45Z,MEMBER,"@spencerahill It sounds like we should just add the function, too, so you can write `xr.where(cond, -2, 0)`. It's a only a few more lines of code.","{""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,246502828
https://github.com/pydata/xarray/pull/1496#issuecomment-318957832,https://api.github.com/repos/pydata/xarray/issues/1496,318957832,MDEyOklzc3VlQ29tbWVudDMxODk1NzgzMg==,6200806,2017-07-31T03:18:44Z,2017-07-31T03:18:44Z,CONTRIBUTOR,"Thanks @shoyer. I guess what I had in mind is the case where both `x` and `y` are scalars, while `cond` is still a condition on `a`. In that case you couldn't do `x.where(cond, y)`; it would require either `a.where(cond, x, y)` or `where(cond, x, y)` being supported. Am I understanding that correctly? (If I'm not being clear, consider a concrete case by plugging in e.g. `x=-2`, `y=0`, and `cond=(a.x + a.y < 5)`.)
`a.where(cond, x, y)` might seem odd, since it doesn't actually retain any of `a`'s values, but then it could retain coordinates and attributes, so it might still be useful. And this differs from `where(cond, x, y)`, which it seems would retain `cond`'s coords and attrs.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,246502828
https://github.com/pydata/xarray/pull/1496#issuecomment-318932648,https://api.github.com/repos/pydata/xarray/issues/1496,318932648,MDEyOklzc3VlQ29tbWVudDMxODkzMjY0OA==,1217238,2017-07-30T21:57:51Z,2017-07-30T21:57:51Z,MEMBER,"> How difficult would it be to include np.where's option to provide values for both where the condition is met and where it isn't?
That works, too, e.g.,
```
In [6]: a.where(a.x + a.y < 5, -a)
Out[6]:
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, -9],
[ 10, 11, 12, -13, -14],
[ 15, 16, -17, -18, -19],
[ 20, -21, -22, -23, -24]])
Dimensions without coordinates: x, y
```
You can even put Dataset objects in any of the arguments and it should broadcast across variables.
One annoyance is that instead of `where(cond, x, y)`, you need to write this in the slightly counter-intuitive form `x.where(cond, y)`. This is consistent with pandas, but we could also consider exposing the `where(cond, x, y)` version publicly as a function.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,246502828
https://github.com/pydata/xarray/pull/1496#issuecomment-318931493,https://api.github.com/repos/pydata/xarray/issues/1496,318931493,MDEyOklzc3VlQ29tbWVudDMxODkzMTQ5Mw==,6200806,2017-07-30T21:38:45Z,2017-07-30T21:38:45Z,CONTRIBUTOR,"How difficult would it be to include `np.where`'s option to provide values for both where the condition is met and where it isn't? From their docstring:
>If both x and y are specified, the output array contains elements of x where condition is True, and elements from y elsewhere.
From your example above (haven't gone through the code), what you have implemented in this PR is a special case, namely the xarray analog to `np.where(a.x + a.y < 5, a, -1)`.
I recently had a usecase where this would be handy.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,246502828
https://github.com/pydata/xarray/pull/1496#issuecomment-318872962,https://api.github.com/repos/pydata/xarray/issues/1496,318872962,MDEyOklzc3VlQ29tbWVudDMxODg3Mjk2Mg==,1217238,2017-07-30T02:19:26Z,2017-07-30T02:19:26Z,MEMBER,"One design decision here is how to handle alignment. The current version of `where` does an inner join between `self` and `cond`, but that wasn't carefully thought through -- more a side effect of making using of the binary arithmetic machinery.
I don't like this behavior for the three argument version of `where`, because it means that the indexes of `other` could remove non-NA values from the result, even if the condition is always `True`. This goes against one of our general principles, which is not aligning away non-missing values.
We can't use an outer join because we don't know how to handle NaNs in `cond`. We have a couple of other options:
1. We could require exact alignment for the three argument signature. This is simple and we already have the machinery.
2. We could require exact alignment to `cond`, but do some sort of more flexible alignment (e.g., an outer join) for `self` and `other`. This would require (at least) two calls to `align()` when `other` is provided, e.g., possibly
```
self, other = align(self, other, join='outer')
self, other, cond = align(self, other, cond, join='inner')
# still need to handle aligning data variables for Dataset objects
```
I am inclined to require exact alignment (i.e., `join='exact'`) when three arguments are provided, because I know how to implement it correctly, and it still preserves the option of switching to more flexible alignment in the future.","{""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,246502828