Skip to content

Commit 8c7d6cf

Browse files
author
darothen
committed
Add note about monotonicity assumption before interpolation
1 parent 5d23a99 commit 8c7d6cf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

xarray/core/resample.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Resample(object):
1717
for handling specialized re-sampling operations.
1818
1919
You should create a `Resample` object by using the `DataArray.resample` or
20-
`Dataset.resample` methods.
20+
`Dataset.resample` methods. The dimension along re-sampling
2121
2222
See Also
2323
--------
@@ -302,7 +302,7 @@ def reduce(self, func, dim=None, keep_attrs=False, **kwargs):
302302

303303
def _interpolate(self, kind='linear'):
304304
from .dataset import Dataset
305-
from .variable import Variable
305+
from .variable import Variable
306306

307307
old_times = self._obj[self._dim].astype(float)
308308
new_times = self._full_index.values.astype(float)
@@ -324,6 +324,10 @@ def _interpolate(self, kind='linear'):
324324

325325
axis = variable.get_axis_num(self._dim)
326326

327+
# We've previously checked for monotonicity along the
328+
# re-sampling dimension (in __init__ via the GroupBy
329+
# constructor), so we can avoid sorting the data again by
330+
# passing 'assume_sorted=True'
327331
f = interp1d(old_times, variable.data, kind=kind,
328332
axis=axis, bounds_error=True,
329333
assume_sorted=True)

0 commit comments

Comments
 (0)