From 70dd61817e5f2458e2290563ba5b7a5d7eb39971 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 15 Mar 2024 11:05:49 -0600 Subject: [PATCH 1/4] Fix upstream-dev CI Closes #337 --- flox/xarray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flox/xarray.py b/flox/xarray.py index 7f0f95d0f..123478ff0 100644 --- a/flox/xarray.py +++ b/flox/xarray.py @@ -259,7 +259,7 @@ def xarray_reduce( for var in maybe_drop: maybe_midx = ds._indexes.get(var, None) if isinstance(maybe_midx, PandasMultiIndex): - idx_coord_names = set(maybe_midx.index.names + [maybe_midx.dim]) + idx_coord_names = set(maybe_midx.index.names + (maybe_midx.dim,)) idx_other_names = idx_coord_names - set(maybe_drop) more_drop.update(idx_other_names) maybe_drop.update(more_drop) From 4721f8c321b771e5541f9ca4bcb6fb7507e32c4c Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 15 Mar 2024 11:08:17 -0600 Subject: [PATCH 2/4] silence warnings --- tests/test_core.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index 11cd19e3e..26c75a855 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -880,7 +880,7 @@ def test_find_cohorts_missing_groups(): @pytest.mark.parametrize("chunksize", [12, 13, 14, 24, 36, 48, 72, 71]) def test_verify_complex_cohorts(chunksize: int) -> None: - time = pd.Series(pd.date_range("2016-01-01", "2018-12-31 23:59", freq="H")) + time = pd.Series(pd.date_range("2016-01-01", "2018-12-31 23:59", freq="h")) chunks = (chunksize,) * (len(time) // chunksize) by = np.array(time.dt.dayofyear.values) @@ -1063,7 +1063,7 @@ def test_empty_bins(func, engine): def test_datetime_binning(): - time_bins = pd.date_range(start="2010-08-01", end="2010-08-15", freq="24H") + time_bins = pd.date_range(start="2010-08-01", end="2010-08-15", freq="24h") by = pd.date_range("2010-08-01", "2010-08-15", freq="15min") (actual,) = _convert_expected_groups_to_index((time_bins,), isbin=(True,), sort=False) @@ -1125,7 +1125,7 @@ def test_group_by_datetime(engine, method): if method == "blockwise": return None - edges = pd.date_range("1999-12-31", "2000-12-31", freq="M").to_series().to_numpy() + edges = pd.date_range("1999-12-31", "2000-12-31", freq="ME").to_series().to_numpy() actual, _ = groupby_reduce(daskarray, t.to_numpy(), isbin=True, expected_groups=edges, **kwargs) expected = data.resample("M").mean().to_numpy() assert_equal(expected, actual) @@ -1520,7 +1520,7 @@ def test_validate_reindex() -> None: @requires_dask def test_1d_blockwise_sort_optimization(): # Make sure for resampling problems sorting isn't done. - time = pd.Series(pd.date_range("2020-09-01", "2020-12-31 23:59", freq="3H")) + time = pd.Series(pd.date_range("2020-09-01", "2020-12-31 23:59", freq="3h")) array = dask.array.ones((len(time),), chunks=(224,)) actual, _ = groupby_reduce(array, time.dt.dayofyear.values, method="blockwise", func="count") @@ -1682,6 +1682,8 @@ def test_multiple_quantiles(q, chunk, func, by_ndim): actual, _ = groupby_reduce(array, labels, func=func, finalize_kwargs=dict(q=q), axis=axis) sorted_array = array[..., [0, 1, 2, 4, 3, 5, 6]] f = partial(getattr(np, func), q=q, axis=axis, keepdims=True) + if chunk: + sorted_array = sorted_array.compute() expected = np.concatenate((f(sorted_array[..., :4]), f(sorted_array[..., 4:])), axis=-1) if by_ndim == 2: expected = expected.squeeze(axis=-2) From 6bba860c2a159603190ff2286018598c02fad48b Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 15 Mar 2024 11:13:03 -0600 Subject: [PATCH 3/4] fix mypy --- flox/xarray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flox/xarray.py b/flox/xarray.py index 123478ff0..0a299d6d5 100644 --- a/flox/xarray.py +++ b/flox/xarray.py @@ -259,7 +259,7 @@ def xarray_reduce( for var in maybe_drop: maybe_midx = ds._indexes.get(var, None) if isinstance(maybe_midx, PandasMultiIndex): - idx_coord_names = set(maybe_midx.index.names + (maybe_midx.dim,)) + idx_coord_names = set(tuple(maybe_midx.index.names) + (maybe_midx.dim,)) idx_other_names = idx_coord_names - set(maybe_drop) more_drop.update(idx_other_names) maybe_drop.update(more_drop) From 7f975068eed6fc9c04815f306993da3aea564a72 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 15 Mar 2024 11:40:43 -0600 Subject: [PATCH 4/4] Trigger upstream workflow --- .github/workflows/upstream-dev-ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/upstream-dev-ci.yaml b/.github/workflows/upstream-dev-ci.yaml index d381eda66..fdaafdb64 100644 --- a/.github/workflows/upstream-dev-ci.yaml +++ b/.github/workflows/upstream-dev-ci.yaml @@ -10,6 +10,7 @@ on: paths: - ".github/workflows/upstream-dev-ci.yaml" - "ci/upstream-dev-env.yml" + - "flox/*" schedule: - cron: "0 0 * * *" # Daily “At 00:00” UTC workflow_dispatch: # allows you to trigger the workflow run manually