8000 Drop groups associated with nans in group variable by dcherian · Pull Request #3406 · pydata/xarray · GitHub
[go: up one dir, main page]

Skip to content

Drop groups associated with nans in group variable #3406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 28, 2019
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/master' into fix/groupby-nan
* upstream/master:
  Another groupby.reduce bugfix. (#3403)
  add icomoon license (#3448)
  change ALL_DIMS to equal ellipsis (#3418)
  Escaping dtypes (#3444)
  Html repr (#3425)
  • Loading branch information
dcherian committed Oct 28, 2019
commit c396381ddbf9f803da9bc7e8ddba737c7f50715c
23 changes: 18 additions & 5 deletions xarray/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
from . import assert_equal, assert_identical, raises_regex


@pytest.fixture
def dataset():
ds = xr.Dataset(
{"foo": (("x", "y", "z"), np.random.randn(3, 4, 2))},
{"x": ["a", "b", "c"], "y": [1, 2, 3, 4], "z": [1, 2]},
)
ds["boo"] = (("z", "y"), [["f", "g", "h", "j"]] * 2)

return ds


@pytest.fixture
def array(dataset):
return dataset["foo"]


def test_consolidate_slices():

assert _consolidate_slices([slice(3), slice(3, 5)]) == [slice(5)]
Expand All @@ -31,10 +47,7 @@ def test_groupby_dims_property(dataset):

def test_multi_index_groupby_apply(dataset):
# regression test for GH873
ds = xr.Dataset(
{"foo": (("x", "y"), np.random.randn(3, 4))},
{"x": ["a", "b", "c"], "y": [1, 2, 3, 4]},
)
ds = dataset.isel(z=1, drop=True)[["foo"]]
expected = 2 * ds
actual = (
ds.stack(space=["x", "y"])
Expand Down Expand Up @@ -352,7 +365,7 @@ def test_groupby_reduce_dimension_error(array):
assert_identical(array, grouped.mean())

assert_identical(array.mean("x"), grouped.reduce(np.mean, "x"))
assert_allclose(array.mean(["x", "z"]), grouped.reduce(np.mean, ["x", "z"]))
assert_equal(array.mean(["x", "z"]), grouped.reduce(np.mean, ["x", "z"]))


def test_groupby_bins_timeseries():
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0