Skip to content

Commit 22bd964

Browse files
Update pre-commit hooks (#10510)
* Update pre-commit hooks updates: - [github.com/astral-sh/ruff-pre-commit: v0.12.1 → v0.12.2](astral-sh/ruff-pre-commit@v0.12.1...v0.12.2) - [github.com/keewis/blackdoc: v0.3.9 → v0.4.1](keewis/blackdoc@v0.3.9...v0.4.1) - [github.com/rbubley/mirrors-prettier: v3.5.3 → v3.6.2](rbubley/mirrors-prettier@v3.5.3...v3.6.2) - [github.com/pre-commit/mirrors-mypy: v1.16.0 → v1.16.1](pre-commit/mirrors-mypy@v1.16.0...v1.16.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove unbalanced paren * remove indents --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Justus Magin <keewis@posteo.de>
1 parent ceaca47 commit 22bd964

File tree

7 files changed

+114
-115
lines changed

7 files changed

+114
-115
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,24 @@ repos:
2424
- id: rst-inline-touching-normal
2525
- id: text-unicode-replacement-char
2626
- repo: https://github.com/astral-sh/ruff-pre-commit
27-
rev: v0.12.1
27+
rev: v0.12.2
2828
hooks:
2929
- id: ruff-check
3030
args: ["--fix", "--show-fixes"]
3131
- id: ruff-format
3232
- repo: https://github.com/keewis/blackdoc
33-
rev: v0.3.9
33+
rev: v0.4.1
3434
hooks:
3535
- id: blackdoc
3636
exclude: "generate_aggregations.py"
3737
additional_dependencies: ["black==24.8.0"]
3838
- repo: https://github.com/rbubley/mirrors-prettier
39-
rev: v3.5.3
39+
rev: v3.6.2
4040
hooks:
4141
- id: prettier
4242
args: [--cache-location=.prettier_cache/cache]
4343
- repo: https://github.com/pre-commit/mirrors-mypy
44-
rev: v1.16.0
44+
rev: v1.16.1
4545
hooks:
4646
- id: mypy
4747
# Copied from setup.cfg

HOW_TO_RELEASE.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ upstream https://github.com/pydata/xarray (push)
110110
(Note that repo branch restrictions prevent pushing to `main`, so you have to just-self-merge this.)
111111

112112
13. Update the version available on pyodide:
113-
114113
- Open the PyPI page for [Xarray downloads](https://pypi.org/project/xarray/#files)
115114
- Edit [`pyodide/packages/xarray/meta.yaml`](https://github.com/pyodide/pyodide/blob/main/packages/xarray/meta.yaml) to update the
116115
- version number
@@ -121,7 +120,6 @@ upstream https://github.com/pydata/xarray (push)
121120
14. Issue the release announcement to mailing lists & Twitter (X). For bug fix releases, I
122121
usually only email xarray@googlegroups.com. For major/feature releases, I will email a broader
123122
list (no more than once every 3-6 months):
124-
125123
- pydata@googlegroups.com
126124
- xarray@googlegroups.com
127125
- numpy-discussion@scipy.org

asv_bench/benchmarks/README_CI.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ To minimize the time required to run the full suite, we trimmed the parameter ma
115115
```python
116116
from . import _skip_slow # this function is defined in benchmarks.__init__
117117

118+
118119
def time_something_slow():
119120
pass
120121

122+
121123
time_something.setup = _skip_slow
122124
```

design_notes/flexible_indexes_notes.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ The new `indexes` argument of Dataset/DataArray constructors may be used to spec
9797
```python
9898
>>> da = xr.DataArray(
9999
... data=[[275.2, 273.5], [270.8, 278.6]],
100-
... dims=('x', 'y'),
100+
... dims=("x", "y"),
101101
... coords={
102-
... 'lat': (('x', 'y'), [[45.6, 46.5], [50.2, 51.6]]),
103-
... 'lon': (('x', 'y'), [[5.7, 10.5], [6.2, 12.8]]),
102+
... "lat": (("x", "y"), [[45.6, 46.5], [50.2, 51.6]]),
103+
... "lon": (("x", "y"), [[5.7, 10.5], [6.2, 12.8]]),
104104
... },
105-
... indexes={('lat', 'lon'): SpatialIndex},
105+
... indexes={("lat", "lon"): SpatialIndex},
106106
... )
107107
<xarray.DataArray (x: 2, y: 2)>
108108
array([[275.2, 273.5],
@@ -120,7 +120,7 @@ More formally, `indexes` would accept `Mapping[CoordinateNames, IndexSpec]` wher
120120
Currently index objects like `pandas.MultiIndex` can be passed directly to `coords`, which in this specific case results in the implicit creation of virtual coordinates. With the new `indexes` argument this behavior may become even more confusing than it currently is. For the sake of clarity, it would be appropriate to eventually drop support for this specific behavior and treat any given mapping value given in `coords` as an array that can be wrapped into an Xarray variable, i.e., in the case of a multi-index:
121121

122122
```python
123-
>>> xr.DataArray([1.0, 2.0], dims='x', coords={'x': midx})
123+
>>> xr.DataArray([1.0, 2.0], dims="x", coords={"x": midx})
124124
<xarray.DataArray (x: 2)>
125125
array([1., 2.])
126126
Coordinates:
@@ -169,8 +169,8 @@ Like for the indexes, explicit coordinate creation should be preferred over impl
169169
For example, it is currently possible to pass a `pandas.MultiIndex` object as a coordinate to the Dataset/DataArray constructor:
170170

171171
```python
172-
>>> midx = pd.MultiIndex.from_arrays([['a', 'b'], [0, 1]], names=['lvl1', 'lvl2'])
173-
>>> da = xr.DataArray([1.0, 2.0], dims='x', coords={'x': midx})
172+
>>> midx = pd.MultiIndex.from_arrays([["a", "b"], [0, 1]], names=["lvl1", "lvl2"])
173+
>>> da = xr.DataArray([1.0, 2.0], dims="x", coords={"x": midx})
174174
>>> da
175175
<xarray.DataArray (x: 2)>
176176
array([1., 2.])
@@ -201,7 +201,9 @@ Besides `pandas.MultiIndex`, there may be other situations where we would like t
201201
The example given here is quite confusing, though: this is not an easily predictable behavior. We could entirely avoid the implicit creation of coordinates, e.g., using a helper function that generates coordinate + index dictionaries that we could then pass directly to the DataArray/Dataset constructor:
202202

203203
```python
204-
>>> coords_dict, index_dict = create_coords_from_index(midx, dims='x', include_dim_coord=True)
204+
>>> coords_dict, index_dict = create_coords_from_index(
205+
... midx, dims="x", include_dim_coord=True
206+
... )
205207
>>> coords_dict
206208
{'x': <xarray.Variable (x: 2)>
207209
array([('a', 0), ('b', 1)], dtype=object),
@@ -211,7 +213,7 @@ The example given here is quite confusing, though: this is not an easily predict
211213
array([0, 1])}
212214
>>> index_dict
213215
{('lvl1', 'lvl2'): midx}
214-
>>> xr.DataArray([1.0, 2.0], dims='x', coords=coords_dict, indexes=index_dict)
216+
>>> xr.DataArray([1.0, 2.0], dims="x", coords=coords_dict, indexes=index_dict)
215217
<xarray.DataArray (x: 2)>
216218
array([1., 2.])
217219
Coordinates:

design_notes/grouper_objects.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
I propose the addition of Grouper objects to Xarray's public API so that
99

1010
```python
11-
Dataset.groupby(x=BinGrouper(bins=np.arange(10, 2))))
11+
Dataset.groupby(x=BinGrouper(bins=np.arange(10, 2)))
1212
```
1313

1414
is identical to today's syntax:
@@ -27,7 +27,7 @@ results = []
2727
for element in unique_labels:
2828
subset = ds.sel(x=(ds.x == element)) # split
2929
# subset = ds.where(ds.x == element, drop=True) # alternative
30-
result = subset.mean() # apply
30+
result = subset.mean() # apply
3131
results.append(result)
3232

3333
xr.concat(results) # combine
@@ -36,7 +36,7 @@ xr.concat(results) # combine
3636
to
3737

3838
```python
39-
ds.groupby('x').mean() # splits, applies, and combines
39+
ds.groupby("x").mean() # splits, applies, and combines
4040
```
4141

4242
Efficient vectorized implementations of this pattern are implemented in numpy's [`ufunc.at`](https://numpy.org/doc/stable/reference/generated/numpy.ufunc.at.html), [`ufunc.reduceat`](https://numpy.org/doc/stable/reference/generated/numpy.ufunc.reduceat.html), [`numbagg.grouped`](https://github.com/numbagg/numbagg/blob/main/numbagg/grouped.py), [`numpy_groupies`](https://github.com/ml31415/numpy-groupies), and probably more.
@@ -110,11 +110,13 @@ All Grouper objects will subclass from a Grouper object
110110
```python
111111
import abc
112112

113+
113114
class Grouper(abc.ABC):
114115
@abc.abstractmethod
115116
def factorize(self, by: DataArray):
116117
raise NotImplementedError
117118

119+
118120
class CustomGrouper(Grouper):
119121
def factorize(self, by: DataArray):
120122
...

0 commit comments

Comments
 (0)