Skip to content

Commit a92c431

Browse files
committed
Update via comments
1 parent d73d1d5 commit a92c431

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

doc/computation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ the excess entries or padding ``nan`` to insufficient entries,
231231
da.coarsen(time=30, x=2, boundary='trim').mean()
232232
233233
If you want to apply a specific function to coordinate, you can pass the
234-
function of function name to ``coordinate_func`` option,
234+
function of function name to ``coord_func`` option,
235235

236236
.. ipython:: python
237237
238-
da.coarsen(time=7, x=2, coordinate_func={'time': 'min'}).mean()
238+
da.coarsen(time=7, x=2, coord_func={'time': 'min'}).mean()
239239
240240
241241
Computation using Coordinates

xarray/core/variable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,8 +1696,8 @@ def _coarsen_reshape(self, windows, boundary, side):
16961696
variable = variable.pad_with_fill_value(pad_widths)
16971697
else:
16981698
raise TypeError(
1699-
'{} is invalid for boundary. Valid option is \'exact\', '
1700-
'\'trim\' and \'pad\''.format(boundary[d]))
1699+
"{} is invalid for boundary. Valid option is 'exact', "
1700+
"'trim' and 'pad'".format(boundary[d]))
17011701

17021702
shape = []
17031703
axes = []

xarray/tests/test_dataset.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4462,7 +4462,6 @@ def test_coarsen_coords(ds, dask):
44624462
# should be no error
44634463
ds.isel(x=slice(0, 3 * (len(ds['x']) // 3))).coarsen(x=3).mean()
44644464

4465-
# raise if exact
44664465
# working test with pd.time
44674466
da = xr.DataArray(
44684467
np.linspace(0, 365, num=364), dims='time',

xarray/tests/test_variable.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,15 @@ def test_coarsen(self):
17011701
({'x': 2, 'y': 3}, np.max, 'left', {'x': 'pad', 'y': 'trim'})]:
17021702
v.coarsen(windows, func, boundary, side)
17031703

1704+
def test_coarsen_2d(self):
1705+
v = self.cls(['x', 'y'], np.arange(6 * 12).reshape(6, 12))
1706+
actual = v.coarsen({'x': 3, 'y': 4}, func='mean')
1707+
assert actual.shape == (2, 3)
1708+
1709+
v = self.cls(['x', 'y'], np.arange(7 * 12).reshape(7, 12))
1710+
actual = v.coarsen({'x': 3, 'y': 4}, func='mean', boundary='trim')
1711+
assert actual.shape == (2, 3)
1712+
17041713

17051714
@requires_dask
17061715
class TestVariableWithDask(VariableSubclassobjects):
@@ -1855,6 +1864,10 @@ def test_pad(self):
18551864
def test_rolling_window(self):
18561865
super(TestIndexVariable, self).test_rolling_window()
18571866

1867+
@pytest.mark.xfail
1868+
def test_coarsen_2d(self):
1869+
super(TestIndexVariable, self).test_coarsen_2d()
1870+
18581871

18591872
class TestAsCompatibleData(object):
18601873
def test_unchanged_types(self):

0 commit comments

Comments
 (0)