From c7f86bc2b7722fae779475e4c9425031f57cb723 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Sat, 7 Sep 2024 22:25:25 -0600 Subject: [PATCH 1/6] Revert "[revert] test with Xarray PR branch" This reverts commit 4a59ffa2cdfcb2d4fc662f451d153d68cf77a5b2. --- .github/workflows/ci.yaml | 3 +-- ci/environment.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bbee1506..c470128b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -99,7 +99,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - repository: "dcherian/xarray" + repository: "pydata/xarray" fetch-depth: 0 # Fetch all history for all branches and tags. - name: Set up conda environment uses: mamba-org/setup-micromamba@v1 @@ -113,7 +113,6 @@ jobs: pint>=0.22 - name: Install xarray run: | - git checkout flox-preserve-dtype python -m pip install --no-deps . - name: Install upstream flox run: | diff --git a/ci/environment.yml b/ci/environment.yml index dac6880a..82995d07 100644 --- a/ci/environment.yml +++ b/ci/environment.yml @@ -19,6 +19,7 @@ dependencies: - pytest-pretty - pytest-xdist - syrupy + - xarray - pre-commit - numpy_groupies>=0.9.19 - pooch @@ -26,5 +27,3 @@ dependencies: - numba - numbagg>=0.3 - hypothesis - - pip: - - git+https://github.com/dcherian/xarray.git@flox-preserve-dtype From 2bf4606041d12d1e371c0d1ab29b8db433e7d2a6 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Sat, 14 Sep 2024 19:33:21 -0600 Subject: [PATCH 2/6] fix --- flox/core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flox/core.py b/flox/core.py index c419f746..7cab9b39 100644 --- a/flox/core.py +++ b/flox/core.py @@ -642,6 +642,7 @@ def rechunk_for_blockwise(array: DaskArray, axis: T_Axis, labels: np.ndarray) -> DaskArray Rechunked array """ + # TODO: this should be unnecessary? labels = factorize_((labels,), axes=())[0] chunks = array.chunks[axis] newchunks = _get_optimal_chunks_for_groups(chunks, labels) @@ -2623,7 +2624,8 @@ def groupby_reduce( partial_agg = partial(dask_groupby_agg, **kwargs) - if method == "blockwise" and by_.ndim == 1: + # if preferred method is already blockwise, no need to rechunk + if preferred_method != "blockwise" and method == "blockwise" and by_.ndim == 1: array = rechunk_for_blockwise(array, axis=-1, labels=by_) result, groups = partial_agg( From 59b4f15a40785b126b347205f9db7cc74ded4d0f Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Sat, 14 Sep 2024 19:49:16 -0600 Subject: [PATCH 3/6] one mroe --- ci/no-dask.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci/no-dask.yml b/ci/no-dask.yml index fb2bac92..4978c5bf 100644 --- a/ci/no-dask.yml +++ b/ci/no-dask.yml @@ -21,5 +21,4 @@ dependencies: - toolz - numba - numbagg>=0.3 - - pip: - - git+https://github.com/dcherian/xarray.git@flox-preserve-dtype + - xarray From e4ef7b8cd236ed45f812e8e1c34a223ae57caa27 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Mon, 21 Oct 2024 16:23:38 -0600 Subject: [PATCH 4/6] one more --- ci/env-numpy1.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci/env-numpy1.yml b/ci/env-numpy1.yml index 30dccdc0..6f44f143 100644 --- a/ci/env-numpy1.yml +++ b/ci/env-numpy1.yml @@ -26,5 +26,4 @@ dependencies: - numba - numbagg>=0.3 - hypothesis - - pip: - - git+https://github.com/dcherian/xarray.git@flox-preserve-dtype + - xarray From bd889ecb9ffbe3162f244744cc8d7baa9e0baf59 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Mon, 21 Oct 2024 16:31:20 -0600 Subject: [PATCH 5/6] fix typing --- flox/aggregations.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flox/aggregations.py b/flox/aggregations.py index 0906c8cc..0ad659f4 100644 --- a/flox/aggregations.py +++ b/flox/aggregations.py @@ -149,9 +149,9 @@ def size(self) -> int: class Aggregation: def __init__( self, - name, + name: str, *, - numpy: str | FuncTuple | None = None, + numpy: str | None = None, chunk: str | FuncTuple | None, combine: str | FuncTuple | None, preprocess: Callable | None = None, @@ -217,7 +217,7 @@ def __init__( self.preprocess = preprocess # Use "chunk_reduce" or "chunk_argreduce" self.reduction_type = reduction_type - self.numpy: FuncTuple = (numpy,) if numpy else (self.name,) + self.numpy: FuncTuple = (numpy,) if numpy is not None else (self.name,) # initialize blockwise reduction self.chunk: OptionalFuncTuple = _atleast_1d(chunk) # how to aggregate results after first round of reduction From 7ae731e37e3947bc58efa7a4dfedc6022d3a7792 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Mon, 21 Oct 2024 17:02:47 -0600 Subject: [PATCH 6/6] Use xarray main instead --- ci/env-numpy1.yml | 3 ++- ci/environment.yml | 3 ++- ci/no-dask.yml | 3 ++- ci/no-numba.yml | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ci/env-numpy1.yml b/ci/env-numpy1.yml index 6f44f143..4ee2dd23 100644 --- a/ci/env-numpy1.yml +++ b/ci/env-numpy1.yml @@ -26,4 +26,5 @@ dependencies: - numba - numbagg>=0.3 - hypothesis - - xarray + - pip: + - git+https://github.com/dcherian/xarray.git diff --git a/ci/environment.yml b/ci/environment.yml index 82995d07..970543e6 100644 --- a/ci/environment.yml +++ b/ci/environment.yml @@ -19,7 +19,6 @@ dependencies: - pytest-pretty - pytest-xdist - syrupy - - xarray - pre-commit - numpy_groupies>=0.9.19 - pooch @@ -27,3 +26,5 @@ dependencies: - numba - numbagg>=0.3 - hypothesis + - pip: + - git+https://github.com/dcherian/xarray.git diff --git a/ci/no-dask.yml b/ci/no-dask.yml index 4978c5bf..a6492e26 100644 --- a/ci/no-dask.yml +++ b/ci/no-dask.yml @@ -21,4 +21,5 @@ dependencies: - toolz - numba - numbagg>=0.3 - - xarray + - pip: + - git+https://github.com/dcherian/xarray.git diff --git a/ci/no-numba.yml b/ci/no-numba.yml index 8039b20f..10de5d5d 100644 --- a/ci/no-numba.yml +++ b/ci/no-numba.yml @@ -19,8 +19,9 @@ dependencies: - pytest-pretty - pytest-xdist - syrupy - - xarray - pre-commit - numpy_groupies>=0.9.19 - pooch - toolz + - pip: + - git+https://github.com/dcherian/xarray.git