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/3302#issuecomment-549595749,https://api.github.com/repos/pydata/xarray/issues/3302,549595749,MDEyOklzc3VlQ29tbWVudDU0OTU5NTc0OQ==,13837821,2019-11-04T23:34:12Z,2019-11-04T23:34:12Z,CONTRIBUTOR,Thanks for all your work @dcherian! Did a quick test with some real-world timeseries data I've been wanting to use with `max_gap` and it looks good to me. I will definitely be using this in the future! 👍 ,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,492866552
https://github.com/pydata/xarray/pull/3302#issuecomment-543393942,https://api.github.com/repos/pydata/xarray/issues/3302,543393942,MDEyOklzc3VlQ29tbWVudDU0MzM5Mzk0Mg==,13837821,2019-10-17T22:48:45Z,2019-10-17T22:51:36Z,CONTRIBUTOR,"Thanks so much for taking this on. Not sure how I missed the notification that you had done so.
@dcherian I checked out your branch and did some testing and found that testing this against `dim=""x""` fails with a `ValueError`.
```python
arr = np.array([
[np.nan, np.nan, np.nan, 1, 2, 3, 4, np.nan, 6, 7, np.nan, np.nan, np.nan, 11, np.nan, np.nan, ],
[np.nan, np.nan, np.nan, 1, 2, 3, np.nan, np.nan, 6, 7, np.nan, np.nan, np.nan, 11, np.nan, np.nan, ],
[np.nan, np.nan, np.nan, 1, 2, 3, np.nan, np.nan, 6, 7, np.nan, np.nan, np.nan, 11, np.nan, np.nan, ],
[np.nan, np.nan, np.nan, 1, 2, 3, 4, np.nan, 6, 7, np.nan, np.nan, np.nan, 11, np.nan, np.nan, ],
])
da = xr.DataArray(arr, dims=[""x"", ""y""], coords={""x"": np.arange(arr.shape[0]), ""y"": np.arange(arr.shape[1])})
actual = da.interpolate_na(""y"", max_gap=2) # this works as in your test example
actual = da.interpolate_na(""x"", max_gap=2) # this fails
```
Error:
```
>>> actual = da.interpolate_na(""x"", max_gap=2)
Traceback (most recent call last):
File """", line 1, in
File ""/Users/dnowacki/Documents/xarray/xarray/core/dataarray.py"", line 2026, in interpolate_na
**kwargs
File ""/Users/dnowacki/Documents/xarray/xarray/core/missing.py"", line 302, in interp_na
nan_block_lengths = _get_nan_block_lengths(self, dim, index)
File ""/Users/dnowacki/Documents/xarray/xarray/core/missing.py"", line 23, in _get_nan_block_lengths
arange = ones_like(obj) * index + (index[1] - index[0])
File ""/Users/dnowacki/Documents/xarray/xarray/core/dataarray.py"", line 2500, in func
if not reflexive
File ""/Users/dnowacki/Documents/xarray/xarray/core/variable.py"", line 1884, in func
if not reflexive
ValueError: operands could not be broadcast together with shapes (4,16) (4,)
```
I fixed it by changing this line
https://github.com/dcherian/xarray/blob/8899f05a13533e10c8972836afda089b5b792ca0/xarray/core/missing.py#L23
to this:
```python
if index.shape[0] == obj.shape[0]:
arange = ones_like(obj) * index[:, None] + (index[1] - index[0])
else:
arange = ones_like(obj) * index + (index[1] - index[0])
```
Does this seem reasonable?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,492866552
https://github.com/pydata/xarray/pull/3302#issuecomment-531674432,https://api.github.com/repos/pydata/xarray/issues/3302,531674432,MDEyOklzc3VlQ29tbWVudDUzMTY3NDQzMg==,1941408,2019-09-16T07:50:26Z,2019-09-16T07:50:26Z,CONTRIBUTOR,">
>
> Thanks @stefraynaud . I'm having trouble figuring out defining the length of a gap in the irregular coordinate case.
>
> e.g.
>
> ```
> da4 = xr.DataArray([np.nan, np.nan, np.nan, 1, np.nan, np.nan, 4, np.nan, np.nan],
> dims=[""y""], coords={""y"": [0, 2, 5, 6, 7, 8, 10, 12, 14]})
> ```
>
> ```
>
> array([nan, nan, nan, 1., nan, nan, 4., nan, nan])
> Coordinates:
> * y (y) int64 0 2 5 6 7 8 10 12 14
> ```
>
> What is the length of these three gaps given that xarray doesn't have any understanding of grids?
@dcherian In your example, as said @max-sixty, the middle gap has a length of `10-6=4`. The length gaps at the edges cannot be computed but it doesn't matter, and the algo should work as when simply counting the nans.
I'll have a look the code, maybe for a new PR after this one.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,492866552
https://github.com/pydata/xarray/pull/3302#issuecomment-531248632,https://api.github.com/repos/pydata/xarray/issues/3302,531248632,MDEyOklzc3VlQ29tbWVudDUzMTI0ODYzMg==,1941408,2019-09-13T14:00:30Z,2019-09-13T14:00:30Z,CONTRIBUTOR,"Nice feature.
How about adding the support max gaps expressed in physical units, since coordinates may be irregular?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,492866552