Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ repos:
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.1
rev: v0.12.2
hooks:
- id: ruff-format
- id: ruff
args: ["--fix", "--show-fixes"]
- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
rev: v0.4.1
hooks:
- id: blackdoc
exclude: "generate_aggregations.py"
additional_dependencies: ["black==24.8.0"]
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.5.3
rev: v3.6.2
hooks:
- id: prettier
args: [--cache-location=.prettier_cache/cache]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.16.0
rev: v1.16.1
hooks:
- id: mypy
# Copied from setup.cfg
Expand Down
2 changes: 0 additions & 2 deletions HOW_TO_RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ upstream https://github.com/pydata/xarray (push)
(Note that repo branch restrictions prevent pushing to `main`, so you have to just-self-merge this.)

13. Update the version available on pyodide:

- Open the PyPI page for [Xarray downloads](https://pypi.org/project/xarray/#files)
- Edit [`pyodide/packages/xarray/meta.yaml`](https://github.com/pyodide/pyodide/blob/main/packages/xarray/meta.yaml) to update the
- version number
Expand All @@ -121,7 +120,6 @@ upstream https://github.com/pydata/xarray (push)
14. Issue the release announcement to mailing lists & Twitter (X). For bug fix releases, I
usually only email xarray@googlegroups.com. For major/feature releases, I will email a broader
list (no more than once every 3-6 months):

- pydata@googlegroups.com
- xarray@googlegroups.com
- numpy-discussion@scipy.org
Expand Down
2 changes: 2 additions & 0 deletions asv_bench/benchmarks/README_CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ To minimize the time required to run the full suite, we trimmed the parameter ma
```python
from . import _skip_slow # this function is defined in benchmarks.__init__


def time_something_slow():
pass


time_something.setup = _skip_slow
```
20 changes: 11 additions & 9 deletions design_notes/flexible_indexes_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ The new `indexes` argument of Dataset/DataArray constructors may be used to spec
```python
>>> da = xr.DataArray(
... data=[[275.2, 273.5], [270.8, 278.6]],
... dims=('x', 'y'),
... dims=("x", "y"),
... coords={
... 'lat': (('x', 'y'), [[45.6, 46.5], [50.2, 51.6]]),
... 'lon': (('x', 'y'), [[5.7, 10.5], [6.2, 12.8]]),
... "lat": (("x", "y"), [[45.6, 46.5], [50.2, 51.6]]),
... "lon": (("x", "y"), [[5.7, 10.5], [6.2, 12.8]]),
... },
... indexes={('lat', 'lon'): SpatialIndex},
... indexes={("lat", "lon"): SpatialIndex},
... )
<xarray.DataArray (x: 2, y: 2)>
array([[275.2, 273.5],
Expand All @@ -120,7 +120,7 @@ More formally, `indexes` would accept `Mapping[CoordinateNames, IndexSpec]` wher
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:

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

```python
>>> midx = pd.MultiIndex.from_arrays([['a', 'b'], [0, 1]], names=['lvl1', 'lvl2'])
>>> da = xr.DataArray([1.0, 2.0], dims='x', coords={'x': midx})
>>> midx = pd.MultiIndex.from_arrays([["a", "b"], [0, 1]], names=["lvl1", "lvl2"])
>>> da = xr.DataArray([1.0, 2.0], dims="x", coords={"x": midx})
>>> da
<xarray.DataArray (x: 2)>
array([1., 2.])
Expand Down Expand Up @@ -201,7 +201,9 @@ Besides `pandas.MultiIndex`, there may be other situations where we would like t
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:

```python
>>> coords_dict, index_dict = create_coords_from_index(midx, dims='x', include_dim_coord=True)
>>> coords_dict, index_dict = create_coords_from_index(
... midx, dims="x", include_dim_coord=True
... )
>>> coords_dict
{'x': <xarray.Variable (x: 2)>
array([('a', 0), ('b', 1)], dtype=object),
Expand All @@ -211,7 +213,7 @@ The example given here is quite confusing, though: this is not an easily predict
array([0, 1])}
>>> index_dict
{('lvl1', 'lvl2'): midx}
>>> xr.DataArray([1.0, 2.0], dims='x', coords=coords_dict, indexes=index_dict)
>>> xr.DataArray([1.0, 2.0], dims="x", coords=coords_dict, indexes=index_dict)
<xarray.DataArray (x: 2)>
array([1., 2.])
Coordinates:
Expand Down
8 changes: 5 additions & 3 deletions design_notes/grouper_objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
I propose the addition of Grouper objects to Xarray's public API so that

```python
Dataset.groupby(x=BinGrouper(bins=np.arange(10, 2))))
Dataset.groupby(x=BinGrouper(bins=np.arange(10, 2)))
```

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

xr.concat(results) # combine
Expand All @@ -36,7 +36,7 @@ xr.concat(results) # combine
to

```python
ds.groupby('x').mean() # splits, applies, and combines
ds.groupby("x").mean() # splits, applies, and combines
```

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.
Expand Down Expand Up @@ -110,11 +110,13 @@ All Grouper objects will subclass from a Grouper object
```python
import abc


class Grouper(abc.ABC):
@abc.abstractmethod
def factorize(self, by: DataArray):
raise NotImplementedError


class CustomGrouper(Grouper):
def factorize(self, by: DataArray):
...
Expand Down
Loading
Loading