From 382dc143bd2a8ad5d0c36e2bb1a0bf8e720d5321 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 15 Mar 2024 12:17:33 -0600 Subject: [PATCH] Fix upstream-dev CI, silence warnings (#341) * Fix upstream-dev CI Closes #337 * silence warnings * fix mypy * Trigger upstream workflow --- .github/workflows/upstream-dev-ci.yaml | 1 + flox/xarray.py | 2 +- tests/test_core.py | 10 ++++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/upstream-dev-ci.yaml b/.github/workflows/upstream-dev-ci.yaml index d381eda6..fdaafdb6 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 diff --git a/flox/xarray.py b/flox/xarray.py index 7f0f95d0..0a299d6d 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) diff --git a/tests/test_core.py b/tests/test_core.py index 11cd19e3..26c75a85 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)