Skip to content

Commit f49c83a

Browse files
authored
Merge branch 'main' into index-validate-dataarray-coords
2 parents 273d70c + 888dfdb commit f49c83a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1841
-289
lines changed

.github/labeler.yml

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
Automation:
2+
- changed-files:
3+
- any-glob-to-any-file:
4+
- .github/**
5+
6+
CI:
7+
- changed-files:
8+
- any-glob-to-any-file:
9+
- ci/**
10+
11+
dependencies:
12+
- changed-files:
13+
- any-glob-to-any-file:
14+
- ci/requirements/*
15+
16+
topic-arrays:
17+
- changed-files:
18+
- any-glob-to-any-file:
19+
- xarray/core/duck_array_ops.py
20+
21+
topic-backends:
22+
- changed-files:
23+
- any-glob-to-any-file:
24+
- xarray/backends/**
25+
26+
topic-cftime:
27+
- changed-files:
28+
- any-glob-to-any-file:
29+
- xarray/coding/*time*
30+
31+
topic-CF conventions:
32+
- changed-files:
33+
- any-glob-to-any-file:
34+
- xarray/conventions.py
35+
36+
topic-dask:
37+
- changed-files:
38+
- any-glob-to-any-file:
39+
- xarray/compat/dask*
40+
- xarray/core/parallel.py
41+
42+
topic-DataTree:
43+
- changed-files:
44+
- any-glob-to-any-file:
45+
- xarray/core/datatree*
46+
47+
topic-documentation:
48+
- changed-files:
49+
- any-glob-to-any-file:
50+
- doc/*
51+
- "!doc/whats-new.rst"
52+
- doc/**/*
53+
54+
topic-groupby:
55+
- changed-files:
56+
- any-glob-to-any-file:
57+
- xarray/core/groupby.py
58+
59+
topic-html-repr:
60+
- changed-files:
61+
- any-glob-to-any-file:
62+
- xarray/core/formatting_html.py
63+
64+
topic-hypothesis:
65+
- changed-files:
66+
- any-glob-to-any-file:
67+
- properties/**
68+
- xarray/testing/strategies.py
69+
70+
topic-indexing:
71+
- changed-files:
72+
- any-glob-to-any-file:
73+
- xarray/core/indexes.py
74+
- xarray/core/indexing.py
75+
76+
topic-NamedArray:
77+
- changed-files:
78+
- any-glob-to-any-file:
79+
- xarray/namedarray/*
80+
81+
topic-performance:
82+
- changed-files:
83+
- any-glob-to-any-file:
84+
- asv_bench/benchmarks/**
85+
86+
topic-plotting:
87+
- changed-files:
88+
- any-glob-to-any-file:
89+
- xarray/plot/*
90+
- xarray/plot/**/*
91+
92+
topic-rolling:
93+
- changed-files:
94+
- any-glob-to-any-file:
95+
- xarray/computation/rolling.py
96+
- xarray/computation/rolling_exp.py
97+
98+
topic-testing:
99+
- changed-files:
100+
- any-glob-to-any-file:
101+
- conftest.py
102+
- xarray/testing/*
103+
104+
topic-typing:
105+
- changed-files:
106+
- any-glob-to-any-file:
107+
- xarray/core/types.py
108+
109+
topic-zarr:
110+
- changed-files:
111+
- any-glob-to-any-file:
112+
- xarray/backends/zarr.py
113+
114+
io:
115+
- changed-files:
116+
- any-glob-to-any-file:
117+
- xarray/backends/**

.github/workflows/benchmarks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010

1111
jobs:
1212
benchmark:
13-
if: ${{ contains( github.event.pull_request.labels.*.name, 'run-benchmark') && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
13+
if: ${{ contains( github.event.pull_request.labels.*.name, 'run-benchmark') && github.event_name == 'pull_request' || contains( github.event.pull_request.labels.*.name, 'topic-performance') && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
1414
name: Linux
1515
runs-on: ubuntu-20.04
1616
env:

.github/workflows/label-prs.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "PR Labeler"
2+
on:
3+
- pull_request_target
4+
5+
jobs:
6+
label:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/labeler@v5
10+
with:
11+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
12+
sync-labels: false

.github/workflows/nightly-wheels.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
fi
3939
4040
- name: Upload wheel
41-
uses: scientific-python/upload-nightly-action@82396a2ed4269ba06c6b2988bb4fd568ef3c3d6b # 0.6.1
41+
uses: scientific-python/upload-nightly-action@b36e8c0c10dbcfd2e05bf95f17ef8c14fd708dbf # 0.6.2
4242
with:
4343
anaconda_nightly_upload_token: ${{ secrets.ANACONDA_NIGHTLY }}
4444
artifacts_path: dist

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
- id: text-unicode-replacement-char
2626
- repo: https://github.com/astral-sh/ruff-pre-commit
2727
# Ruff version.
28-
rev: v0.9.9
28+
rev: v0.11.4
2929
hooks:
3030
- id: ruff-format
3131
- id: ruff
@@ -69,12 +69,12 @@ repos:
6969
- id: taplo-format
7070
args: ["--option", "array_auto_collapse=false"]
7171
- repo: https://github.com/abravalheri/validate-pyproject
72-
rev: v0.23
72+
rev: v0.24.1
7373
hooks:
7474
- id: validate-pyproject
7575
additional_dependencies: ["validate-pyproject-schema-store[all]"]
7676
- repo: https://github.com/crate-ci/typos
77-
rev: dictgen-v0.3.1
77+
rev: v1
7878
hooks:
7979
- id: typos
8080
# https://github.com/crate-ci/typos/issues/347

asv_bench/benchmarks/repr.py

+19
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@ def time_repr_html(self):
2525
self.ds._repr_html_()
2626

2727

28+
class ReprDataTree:
29+
def setup(self):
30+
# construct a datatree with 500 nodes
31+
number_of_files = 20
32+
number_of_groups = 25
33+
tree_dict = {}
34+
for f in range(number_of_files):
35+
for g in range(number_of_groups):
36+
tree_dict[f"file_{f}/group_{g}"] = xr.Dataset({"g": f * g})
37+
38+
self.dt = xr.DataTree.from_dict(tree_dict)
39+
40+
def time_repr(self):
41+
repr(self.dt)
42+
43+
def time_repr_html(self):
44+
self.dt._repr_html_()
45+
46+
2847
class ReprMultiIndex:
2948
def setup(self):
3049
index = pd.MultiIndex.from_product(

ci/install-upstream-wheels.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ python -m pip install \
5353
git+https://github.com/dask/dask \
5454
git+https://github.com/dask/dask-expr \
5555
git+https://github.com/dask/distributed \
56-
git+https://github.com/zarr-developers/zarr \
56+
git+https://github.com/zarr-developers/zarr-python \
5757
git+https://github.com/Unidata/cftime \
5858
git+https://github.com/pypa/packaging \
5959
git+https://github.com/hgrecco/pint \

ci/requirements/min-all-deps.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ dependencies:
4242
- pandas=2.1
4343
- pint=0.22
4444
- pip
45-
- pydap=3.4
45+
- pydap=3.5.0
4646
- pytest
4747
- pytest-cov
4848
- pytest-env

design_notes/flexible_indexes_notes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Besides `pandas.Index`, other indexes currently supported in Xarray like `CFTime
166166

167167
Like for the indexes, explicit coordinate creation should be preferred over implicit coordinate creation. However, there may be some situations where we would like to keep creating coordinates implicitly for backwards compatibility.
168168

169-
For example, it is currently possible to pass a `pandas.MulitIndex` object as a coordinate to the Dataset/DataArray constructor:
169+
For example, it is currently possible to pass a `pandas.MultiIndex` object as a coordinate to the Dataset/DataArray constructor:
170170

171171
```python
172172
>>> midx = pd.MultiIndex.from_arrays([['a', 'b'], [0, 1]], names=['lvl1', 'lvl2'])

doc/api-hidden.rst

+4
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,10 @@
531531
Index.rename
532532
Index.copy
533533

534+
indexes.RangeIndex.start
535+
indexes.RangeIndex.stop
536+
indexes.RangeIndex.step
537+
534538
backends.NetCDF4DataStore.close
535539
backends.NetCDF4DataStore.encode
536540
backends.NetCDF4DataStore.encode_attribute

doc/api.rst

+3
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,7 @@ Custom Indexes
15731573
:toctree: generated/
15741574

15751575
CFTimeIndex
1576+
indexes.RangeIndex
15761577

15771578
Creating custom indexes
15781579
-----------------------
@@ -1582,6 +1583,8 @@ Creating custom indexes
15821583
cftime_range
15831584
date_range
15841585
date_range_like
1586+
indexes.RangeIndex.arange
1587+
indexes.RangeIndex.linspace
15851588

15861589
Tutorial
15871590
========

doc/getting-started-guide/faq.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ To open format X file in xarray, you need to know the `format of the data <https
191191
:header: "File Format", "Open via", " Related Packages"
192192
:widths: 15, 45, 15
193193

194-
"NetCDF (.nc, .nc4, .cdf)","``open_dataset()`` OR ``open_mfdataset()``", "`netCDF4 <https://pypi.org/project/netCDF4/>`_, `netcdf <https://pypi.org/project/netcdf/>`_ , `cdms2 <https://cdms.readthedocs.io/en/latest/cdms2.html>`_"
194+
"NetCDF (.nc, .nc4, .cdf)","``open_dataset()`` OR ``open_mfdataset()``", "`netCDF4 <https://pypi.org/project/netCDF4/>`_, `cdms2 <https://cdms.readthedocs.io/en/latest/cdms2.html>`_"
195195
"HDF5 (.h5, .hdf5)","``open_dataset()`` OR ``open_mfdataset()``", "`h5py <https://www.h5py.org/>`_, `pytables <https://www.pytables.org/>`_ "
196196
"GRIB (.grb, .grib)", "``open_dataset()``", "`cfgrib <https://pypi.org/project/cfgrib/>`_, `pygrib <https://pypi.org/project/pygrib/>`_"
197197
"CSV (.csv)","``open_dataset()``", "`pandas`_ , `dask <https://www.dask.org/>`_"

doc/getting-started-guide/quick-overview.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Operations also align based on index labels:
128128
129129
data[:-1] - data[:1]
130130
131-
For more, see :ref:`comput`.
131+
For more, see :ref:`compute`.
132132

133133
GroupBy
134134
-------

doc/internals/how-to-create-custom-index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ number, order and dimensions of the coordinates are all arbitrary), it is the
5353
responsibility of the index to check the consistency and validity of those input
5454
coordinates.
5555

56-
For example, :py:class:`~xarray.core.indexes.PandasIndex` accepts only one coordinate and
57-
:py:class:`~xarray.core.indexes.PandasMultiIndex` accepts one or more 1-dimensional coordinates that must all
56+
For example, :py:class:`~xarray.indexes.PandasIndex` accepts only one coordinate and
57+
:py:class:`~xarray.indexes.PandasMultiIndex` accepts one or more 1-dimensional coordinates that must all
5858
share the same dimension. Other, custom indexes need not have the same
5959
constraints, e.g.,
6060

doc/internals/internal-design.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ DataArray Objects
8686

8787
The simplest data structure used by most users is :py:class:`~xarray.DataArray`.
8888
A :py:class:`~xarray.DataArray` is a composite object consisting of multiple
89-
:py:class:`~xarray.core.variable.Variable` objects which store related data.
89+
:py:class:`~xarray.Variable` objects which store related data.
9090

91-
A single :py:class:`~xarray.core.Variable` is referred to as the "data variable", and stored under the :py:attr:`~xarray.DataArray.variable`` attribute.
91+
A single :py:class:`~xarray.Variable` is referred to as the "data variable", and stored under the :py:attr:`~xarray.DataArray.variable`` attribute.
9292
A :py:class:`~xarray.DataArray` inherits all of the properties of this data variable, i.e. ``dims``, ``data``, ``attrs`` and ``encoding``,
9393
all of which are implemented by forwarding on to the underlying ``Variable`` object.
9494

@@ -111,7 +111,7 @@ Finally a :py:class:`~xarray.DataArray` defines a :py:attr:`~xarray.DataArray.na
111111
variable but is stored on the wrapping ``DataArray`` class.
112112
The ``name`` attribute is primarily used when one or more :py:class:`~xarray.DataArray` objects are promoted into a :py:class:`~xarray.Dataset`
113113
(e.g. via :py:meth:`~xarray.DataArray.to_dataset`).
114-
Note that the underlying :py:class:`~xarray.core.Variable` objects are all unnamed, so they can always be referred to uniquely via a
114+
Note that the underlying :py:class:`~xarray.Variable` objects are all unnamed, so they can always be referred to uniquely via a
115115
dict-like mapping.
116116

117117
.. _internal design.dataset:

doc/internals/interoperability.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This interoperability comes via a set of flexible abstractions into which the us
1010

1111
- :ref:`Custom file backends <add_a_backend>` via the :py:class:`~xarray.backends.BackendEntrypoint` system,
1212
- Numpy-like :ref:`"duck" array wrapping <internals.duckarrays>`, which supports the `Python Array API Standard <https://data-apis.org/array-api/latest/>`_,
13-
- :ref:`Chunked distributed array computation <internals.chunkedarrays>` via the :py:class:`~xarray.core.parallelcompat.ChunkManagerEntrypoint` system,
13+
- :ref:`Chunked distributed array computation <internals.chunkedarrays>` via the :py:class:`~xarray.namedarray.parallelcompat.ChunkManagerEntrypoint` system,
1414
- Custom :py:class:`~xarray.Index` objects for :ref:`flexible label-based lookups <internals.custom indexes>`,
1515
- Extending xarray objects with domain-specific methods via :ref:`custom accessors <internals.accessors>`.
1616

doc/internals/time-coding.rst

+17
Original file line numberDiff line numberDiff line change
@@ -535,3 +535,20 @@ To opt-out of timedelta decoding (see issue `Undesired decoding to timedelta64 <
535535
.. note::
536536
Note that in the future the default value of ``decode_timedelta`` will be
537537
``False`` rather than ``None``.
538+
539+
540+
541+
.. ipython:: python
542+
:suppress:
543+
544+
# Cleanup
545+
import os
546+
547+
for f in [
548+
"test-datetimes1.nc",
549+
"test-datetimes2.nc",
550+
"test-timedeltas1.nc",
551+
"test-timedeltas2.nc",
552+
]:
553+
if os.path.exists(f):
554+
os.remove(f)

doc/user-guide/combining.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Combining data
2222
Concatenate
2323
~~~~~~~~~~~
2424

25-
To combine :py:class:`~xarray.Dataset`s / :py:class:`~xarray.DataArray`s along an existing or new dimension
25+
To combine :py:class:`~xarray.Dataset` / :py:class:`~xarray.DataArray` objects along an existing or new dimension
2626
into a larger object, you can use :py:func:`~xarray.concat`. ``concat``
2727
takes an iterable of ``DataArray`` or ``Dataset`` objects, as well as a
2828
dimension name, and concatenates along that dimension:

doc/user-guide/computation.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.. currentmodule:: xarray
22

3-
.. _comput:
3+
.. _compute:
44

55
###########
66
Computation
@@ -236,7 +236,7 @@ These operations automatically skip missing values, like in pandas:
236236
If desired, you can disable this behavior by invoking the aggregation method
237237
with ``skipna=False``.
238238

239-
.. _comput.rolling:
239+
.. _compute.rolling:
240240

241241
Rolling window operations
242242
=========================
@@ -308,7 +308,7 @@ We can also manually iterate through ``Rolling`` objects:
308308
# arr_window is a view of x
309309
...
310310
311-
.. _comput.rolling_exp:
311+
.. _compute.rolling_exp:
312312

313313
While ``rolling`` provides a simple moving average, ``DataArray`` also supports
314314
an exponential moving average with :py:meth:`~xarray.DataArray.rolling_exp`.
@@ -354,7 +354,7 @@ You can also use ``construct`` to compute a weighted rolling sum:
354354
To avoid this, use ``skipna=False`` as the above example.
355355

356356

357-
.. _comput.weighted:
357+
.. _compute.weighted:
358358

359359
Weighted array reductions
360360
=========================
@@ -823,7 +823,7 @@ Arithmetic between two datasets matches data variables of the same name:
823823
Similarly to index based alignment, the result has the intersection of all
824824
matching data variables.
825825

826-
.. _comput.wrapping-custom:
826+
.. _compute.wrapping-custom:
827827

828828
Wrapping custom computation
829829
===========================

doc/user-guide/dask.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ we use to calculate `Spearman's rank-correlation coefficient <https://en.wikiped
282282
283283
The only aspect of this example that is different from standard usage of
284284
``apply_ufunc()`` is that we needed to supply the ``output_dtypes`` arguments.
285-
(Read up on :ref:`comput.wrapping-custom` for an explanation of the
285+
(Read up on :ref:`compute.wrapping-custom` for an explanation of the
286286
"core dimensions" listed in ``input_core_dims``.)
287287

288288
Our new ``spearman_correlation()`` function achieves near linear speedup

0 commit comments

Comments
 (0)