Skip to content

Commit

Permalink
Style and spelling fixes (pydata#3376)
Browse files Browse the repository at this point in the history
  • Loading branch information
amcnicho committed Feb 27, 2020
1 parent ade6a49 commit 523cca4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ def coarsen(
multiple of the window size. If 'trim', the excess entries are
dropped. If 'pad', NA will be padded.
side : 'left' or 'right' or mapping from dimension to 'left' or 'right'
coord_func : function (name) that is applied to the coordintes,
coord_func : function (name) that is applied to the coordinates,
or a mapping from coordinate name to function (name).
keep_attrs : bool, optional
If True, the object's attributes (`attrs`) will be copied from
Expand Down
8 changes: 4 additions & 4 deletions xarray/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5656,22 +5656,22 @@ def test_coarsen_coords_cftime():

def test_coarsen_keep_attrs(self):
_attrs = {"units": "test", "long_name": "testing"}

var1 = np.linspace(10, 15, 100)
var2 = np.linspace(5, 10, 100)
coords = np.linspace(1, 10, 100)

ds = Dataset(
data_vars={"var1": ("coord", var1), "var2": ("coord", var2)},
coords={"coord": coords},
)
ds.attrs["units"] = "test"
ds.attrs["long_name"] = "testing"

# Test dropped attrs
dat = ds.coarsen(coord=5).mean()
assert dat.attrs == {}

# Test kept attrs
dat = ds.coarsen(coord=5, keep_attrs=True).mean()
assert dat.attrs == _attrs
Expand Down
13 changes: 7 additions & 6 deletions xarray/tests/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytz

from xarray import Coordinate, Dataset, IndexVariable, Variable, set_options
from xarray.core import dtypes, indexing, duck_array_ops
from xarray.core import dtypes, duck_array_ops, indexing
from xarray.core.common import full_like, ones_like, zeros_like
from xarray.core.indexing import (
BasicIndexer,
Expand Down Expand Up @@ -1879,7 +1879,6 @@ def test_coarsen_2d(self):
expected = self.cls(("x", "y"), [[10, 18], [42, 35]])
assert_equal(actual, expected)


# perhaps @pytest.mark.parametrize("operation", [f for f in duck_array_ops])
def test_coarsen_keep_attrs(self, operation="mean"):
_attrs = {"units": "test", "long_name": "testing"}
Expand All @@ -1890,14 +1889,16 @@ def test_coarsen_keep_attrs(self, operation="mean"):

# Test dropped attrs
with set_options(keep_attrs=False):
new = coord.coarsen(windows={"coord": 1}, func=test_func,
boundary="exact", side="left")
new = coord.coarsen(
windows={"coord": 1}, func=test_func, boundary="exact", side="left"
)
assert new.attrs == {}

# Test kept attrs
with set_options(keep_attrs=True):
new = coord.coarsen(windows={"coord": 1}, func=test_func,
boundary="exact", side="left")
new = coord.coarsen(
windows={"coord": 1}, func=test_func, boundary="exact", side="left"
)
assert new.attrs == _attrs


Expand Down

0 comments on commit 523cca4

Please sign in to comment.