Skip to content

Commit 412f31f

Browse files
committed
Merge remote-tracking branch 'upstream/main' into numbagg
* upstream/main: Support quantile, median, mode with method="blockwise". (#269) Add multidimensional binning demo (#203) [pre-commit.ci] pre-commit autoupdate (#268)
2 parents e1eda24 + 68b122e commit 412f31f

14 files changed

+628
-61
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44
repos:
55
- repo: https://github.com/astral-sh/ruff-pre-commit
66
# Ruff version.
7-
rev: 'v0.0.276'
7+
rev: 'v0.0.292'
88
hooks:
99
- id: ruff
1010
args: ["--fix"]
@@ -18,12 +18,12 @@ repos:
1818
- id: check-docstring-first
1919

2020
- repo: https://github.com/psf/black
21-
rev: 23.3.0
21+
rev: 23.9.1
2222
hooks:
2323
- id: black
2424

2525
- repo: https://github.com/executablebooks/mdformat
26-
rev: 0.7.16
26+
rev: 0.7.17
2727
hooks:
2828
- id: mdformat
2929
additional_dependencies:
@@ -44,13 +44,13 @@ repos:
4444
args: [--extra-keys=metadata.kernelspec metadata.language_info.version]
4545

4646
- repo: https://github.com/codespell-project/codespell
47-
rev: v2.2.5
47+
rev: v2.2.6
4848
hooks:
4949
- id: codespell
5050
additional_dependencies:
5151
- tomli
5252

5353
- repo: https://github.com/abravalheri/validate-pyproject
54-
rev: v0.13
54+
rev: v0.14
5555
hooks:
5656
- id: validate-pyproject

ci/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ dependencies:
2222
- pooch
2323
- toolz
2424
- numba
25+
- scipy
2526
- pip:
2627
- git+https://github.com/numbagg/numbagg

docs/source/aggregations.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ the `func` kwarg:
1111
- `"std"`, `"nanstd"`
1212
- `"argmin"`
1313
- `"argmax"`
14-
- `"first"`
15-
- `"last"`
14+
- `"first"`, `"nanfirst"`
15+
- `"last"`, `"nanlast"`
16+
- `"median"`, `"nanmedian"`
17+
- `"mode"`, `"nanmode"`
18+
- `"quantile"`, `"nanquantile"`
1619

1720
```{tip}
1821
We would like to add support for `cumsum`, `cumprod` ([issue](https://github.com/xarray-contrib/flox/issues/91)). Contributions are welcome!

docs/source/implementation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ width: 100%
199199
1. Group labels must be known at graph construction time, so this only works for numpy arrays.
200200
1. This does require more tasks and a more complicated graph, but the communication overhead can be significantly lower.
201201
1. The detection of "cohorts" is currently slow but could be improved.
202-
1. The extra effort of detecting cohorts and mul;tiple copying of intermediate blocks may be worthwhile only if the chunk sizes are small
202+
1. The extra effort of detecting cohorts and multiple copying of intermediate blocks may be worthwhile only if the chunk sizes are small
203203
relative to the approximate period of group labels, or small relative to the size of spatially localized groups.
204204

205205
### Example : sensitivity to chunking

docs/source/user-stories.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
user-stories/climatology.ipynb
99
user-stories/climatology-hourly.ipynb
1010
user-stories/custom-aggregations.ipynb
11+
user-stories/nD-bins.ipynb
1112
```

docs/source/user-stories/custom-aggregations.ipynb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
">\n",
1616
"> A = da.groupby(['lon_bins', 'lat_bins']).mode()\n",
1717
"\n",
18-
"This notebook will describe how to accomplish this using a custom `Aggregation`\n",
19-
"since `mode` and `median` aren't supported by flox yet.\n"
18+
"This notebook will describe how to accomplish this using a custom `Aggregation`.\n",
19+
"\n",
20+
"\n",
21+
"```{tip}\n",
22+
"flox now supports `mode`, `nanmode`, `quantile`, `nanquantile`, `median`, `nanmedian` using exactly the same \n",
23+
"approach as shown below\n",
24+
"```\n"
2025
]
2126
},
2227
{
@@ -135,7 +140,7 @@
135140
" # The next are for dask inputs and describe how to reduce\n",
136141
" # the data in parallel\n",
137142
" chunk=(\"sum\", \"nanlen\"), # first compute these blockwise : (grouped_sum, grouped_count)\n",
138-
" combine=(\"sum\", \"sum\"), # reduce intermediate reuslts (sum the sums, sum the counts)\n",
143+
" combine=(\"sum\", \"sum\"), # reduce intermediate results (sum the sums, sum the counts)\n",
139144
" finalize=lambda sum_, count: sum_ / count, # final mean value (divide sum by count)\n",
140145
"\n",
141146
" fill_value=(0, 0), # fill value for intermediate sums and counts when groups have no members\n",

0 commit comments

Comments
 (0)