Skip to content

Commit

Permalink
Update via comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiisoup committed Dec 30, 2018
1 parent d73d1d5 commit a92c431
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions doc/computation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ the excess entries or padding ``nan`` to insufficient entries,
da.coarsen(time=30, x=2, boundary='trim').mean()
If you want to apply a specific function to coordinate, you can pass the
function of function name to ``coordinate_func`` option,
function of function name to ``coord_func`` option,

.. ipython:: python
da.coarsen(time=7, x=2, coordinate_func={'time': 'min'}).mean()
da.coarsen(time=7, x=2, coord_func={'time': 'min'}).mean()
Computation using Coordinates
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1696,8 +1696,8 @@ def _coarsen_reshape(self, windows, boundary, side):
variable = variable.pad_with_fill_value(pad_widths)
else:
raise TypeError(
'{} is invalid for boundary. Valid option is \'exact\', '
'\'trim\' and \'pad\''.format(boundary[d]))
"{} is invalid for boundary. Valid option is 'exact', "
"'trim' and 'pad'".format(boundary[d]))

shape = []
axes = []
Expand Down
1 change: 0 additions & 1 deletion xarray/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4462,7 +4462,6 @@ def test_coarsen_coords(ds, dask):
# should be no error
ds.isel(x=slice(0, 3 * (len(ds['x']) // 3))).coarsen(x=3).mean()

# raise if exact
# working test with pd.time
da = xr.DataArray(
np.linspace(0, 365, num=364), dims='time',
Expand Down
13 changes: 13 additions & 0 deletions xarray/tests/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,15 @@ def test_coarsen(self):
({'x': 2, 'y': 3}, np.max, 'left', {'x': 'pad', 'y': 'trim'})]:
v.coarsen(windows, func, boundary, side)

def test_coarsen_2d(self):
v = self.cls(['x', 'y'], np.arange(6 * 12).reshape(6, 12))
actual = v.coarsen({'x': 3, 'y': 4}, func='mean')
assert actual.shape == (2, 3)

v = self.cls(['x', 'y'], np.arange(7 * 12).reshape(7, 12))
actual = v.coarsen({'x': 3, 'y': 4}, func='mean', boundary='trim')
assert actual.shape == (2, 3)

This comment has been minimized.

Copy link
@shoyer

shoyer Dec 31, 2018

Member

Can we check the actual array values for one of these tests? Otherwise I'm concerned a bug that miscalculated things could sneak through.



@requires_dask
class TestVariableWithDask(VariableSubclassobjects):
Expand Down Expand Up @@ -1855,6 +1864,10 @@ def test_pad(self):
def test_rolling_window(self):
super(TestIndexVariable, self).test_rolling_window()

@pytest.mark.xfail
def test_coarsen_2d(self):
super(TestIndexVariable, self).test_coarsen_2d()


class TestAsCompatibleData(object):
def test_unchanged_types(self):
Expand Down

0 comments on commit a92c431

Please sign in to comment.