Skip to content

Commit 4d14fca

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix/groupby-reduce-multiple-dims
* upstream/master: minor lint tweaks (pydata#3429) Hack around pydata#3440 (pydata#3442) Update Terminology page to account for multidimensional coordinates (pydata#3410) Use cftime master for upstream-dev build (pydata#3439)
2 parents 163bb81 + 652dd3c commit 4d14fca

18 files changed

+56
-67
lines changed

ci/azure/install.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ steps:
1616
--pre \
1717
--upgrade \
1818
matplotlib \
19-
pandas \
19+
pandas=0.26.0.dev0+628.g03c1a3db2 \ # FIXME https://github.com/pydata/xarray/issues/3440
2020
scipy
2121
# numpy \ # FIXME https://github.com/pydata/xarray/issues/3409
2222
pip install \
@@ -25,8 +25,7 @@ steps:
2525
git+https://github.com/dask/dask \
2626
git+https://github.com/dask/distributed \
2727
git+https://github.com/zarr-developers/zarr \
28-
git+https://github.com/Unidata/cftime.git@refs/pull/127/merge
29-
# git+https://github.com/Unidata/cftime # FIXME PR 127 not merged yet
28+
git+https://github.com/Unidata/cftime
3029
condition: eq(variables['UPSTREAM_DEV'], 'true')
3130
displayName: Install upstream dev dependencies
3231

doc/contributing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,12 @@ How to build the *xarray* documentation
286286
Requirements
287287
~~~~~~~~~~~~
288288
Make sure to follow the instructions on :ref:`creating a development environment above <contributing.dev_env>`, but
289-
to build the docs you need to use the environment file ``doc/environment.yml``.
289+
to build the docs you need to use the environment file ``ci/requirements/doc.yml``.
290290

291291
.. code-block:: none
292292
293293
# Create and activate the docs environment
294-
conda env create -f doc/environment.yml
294+
conda env create -f ci/requirements/doc.yml
295295
conda activate xarray-docs
296296
297297
# or with older versions of Anaconda:

doc/terminology.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ Terminology
2727

2828
----
2929

30-
**Coordinate:** An array that labels a dimension of another ``DataArray``. Loosely, the coordinate array's values can be thought of as tick labels along a dimension. There are two types of coordinate arrays: *dimension coordinates* and *non-dimension coordinates* (see below). A coordinate named ``x`` can be retrieved from ``arr.coords[x]``. A ``DataArray`` can have more coordinates than dimensions because a single dimension can be assigned multiple coordinate arrays. However, only one coordinate array can be a assigned as a particular dimension's dimension coordinate array. As a consequence, ``len(arr.dims) <= len(arr.coords)`` in general.
30+
**Coordinate:** An array that labels a dimension or set of dimensions of another ``DataArray``. In the usual one-dimensional case, the coordinate array's values can loosely be thought of as tick labels along a dimension. There are two types of coordinate arrays: *dimension coordinates* and *non-dimension coordinates* (see below). A coordinate named ``x`` can be retrieved from ``arr.coords[x]``. A ``DataArray`` can have more coordinates than dimensions because a single dimension can be labeled by multiple coordinate arrays. However, only one coordinate array can be a assigned as a particular dimension's dimension coordinate array. As a consequence, ``len(arr.dims) <= len(arr.coords)`` in general.
3131

3232
----
3333

34-
**Dimension coordinate:** A coordinate array assigned to ``arr`` with both a name and dimension name in ``arr.dims``. Dimension coordinates are used for label-based indexing and alignment, like the index found on a :py:class:`pandas.DataFrame` or :py:class:`pandas.Series`. In fact, dimension coordinates use :py:class:`pandas.Index` objects under the hood for efficient computation. Dimension coordinates are marked by ``*`` when printing a ``DataArray`` or ``Dataset``.
34+
**Dimension coordinate:** A one-dimensional coordinate array assigned to ``arr`` with both a name and dimension name in ``arr.dims``. Dimension coordinates are used for label-based indexing and alignment, like the index found on a :py:class:`pandas.DataFrame` or :py:class:`pandas.Series`. In fact, dimension coordinates use :py:class:`pandas.Index` objects under the hood for efficient computation. Dimension coordinates are marked by ``*`` when printing a ``DataArray`` or ``Dataset``.
3535

3636
----
3737

38-
**Non-dimension coordinate:** A coordinate array assigned to ``arr`` with a name in ``arr.dims`` but a dimension name *not* in ``arr.dims``. These coordinate arrays are useful for auxiliary labeling. However, non-dimension coordinates are not indexed, and any operation on non-dimension coordinates that leverages indexing will fail. Printing ``arr.coords`` will print all of ``arr``'s coordinate names, with the assigned dimensions in parentheses. For example, ``coord_name (dim_name) 1 2 3 ...``.
38+
**Non-dimension coordinate:** A coordinate array assigned to ``arr`` with a name in ``arr.coords`` but *not* in ``arr.dims``. These coordinates arrays can be one-dimensional or multidimensional, and they are useful for auxiliary labeling. As an example, multidimensional coordinates are often used in geoscience datasets when :doc:`the data's physical coordinates (such as latitude and longitude) differ from their logical coordinates <examples/multidimensional-coords>`. However, non-dimension coordinates are not indexed, and any operation on non-dimension coordinates that leverages indexing will fail. Printing ``arr.coords`` will print all of ``arr``'s coordinate names, with the corresponding dimension(s) in parentheses. For example, ``coord_name (dim_name) 1 2 3 ...``.
3939

4040
----
4141

doc/whats-new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Documentation
5656
:py:meth:`Dataset.resample` and explicitly state that a
5757
datetime-like dimension is required. (:pull:`3400`)
5858
By `Justus Magin <https://github.com/keewis>`_.
59+
- Update the terminology page to address multidimensional coordinates. (:pull:`3410`)
60+
By `Jon Thielen <https://github.com/jthielen>`_.
5961

6062
Internal Changes
6163
~~~~~~~~~~~~~~~~

xarray/backends/h5netcdf_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def prepare_variable(
245245
dtype=dtype,
246246
dimensions=variable.dims,
247247
fillvalue=fillvalue,
248-
**kwargs
248+
**kwargs,
249249
)
250250
else:
251251
nc4_var = self.ds[name]

xarray/backends/zarr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def open_zarr(
467467
drop_variables=None,
468468
consolidated=False,
469469
overwrite_encoded_chunks=False,
470-
**kwargs
470+
**kwargs,
471471
):
472472
"""Load and decode a dataset from a Zarr store.
473473

xarray/core/accessor_dt.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ def __init__(self, obj):
178178
)
179179
self._obj = obj
180180

181-
def _tslib_field_accessor(name, docstring=None, dtype=None):
181+
def _tslib_field_accessor( # type: ignore
182+
name: str, docstring: str = None, dtype: np.dtype = None
183+
):
182184
def f(self, dtype=dtype):
183185
if dtype is None:
184186
dtype = self._obj.dtype

xarray/core/arithmetic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
7676
dataset_join=dataset_join,
7777
dataset_fill_value=np.nan,
7878
kwargs=kwargs,
79-
dask="allowed"
79+
dask="allowed",
8080
)
8181

8282
# this has no runtime function - these are listed so IDEs know these

xarray/core/coordinates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def remap_label_indexers(
367367
indexers: Mapping[Hashable, Any] = None,
368368
method: str = None,
369369
tolerance=None,
370-
**indexers_kwargs: Any
370+
**indexers_kwargs: Any,
371371
) -> Tuple[dict, dict]: # TODO more precise return type after annotations in indexing
372372
"""Remap indexers from obj.coords.
373373
If indexer is an instance of DataArray and it has coordinate, then this coordinate

xarray/core/dataset.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,15 +2967,13 @@ def expand_dims(
29672967
for a in axis:
29682968
if a < -result_ndim or result_ndim - 1 < a:
29692969
raise IndexError(
2970-
"Axis {a} is out of bounds of the expanded"
2971-
" dimension size {dim}.".format(
2972-
a=a, v=k, dim=result_ndim
2973-
)
2970+
f"Axis {a} of variable {k} is out of bounds of the "
2971+
f"expanded dimension size {result_ndim}"
29742972
)
29752973

29762974
axis_pos = [a if a >= 0 else result_ndim + a for a in axis]
29772975
if len(axis_pos) != len(set(axis_pos)):
2978-
raise ValueError("axis should not contain duplicate" " values.")
2976+
raise ValueError("axis should not contain duplicate values")
29792977
# We need to sort them to make sure `axis` equals to the
29802978
# axis positions of the result array.
29812979
zip_axis_dim = sorted(zip(axis_pos, dim.items()))
@@ -3131,7 +3129,7 @@ def reorder_levels(
31313129
coord = self._variables[dim]
31323130
index = self.indexes[dim]
31333131
if not isinstance(index, pd.MultiIndex):
3134-
raise ValueError("coordinate %r has no MultiIndex" % dim)
3132+
raise ValueError(f"coordinate {dim} has no MultiIndex")
31353133
new_index = index.reorder_levels(order)
31363134
variables[dim] = IndexVariable(coord.dims, new_index)
31373135
indexes[dim] = new_index

0 commit comments

Comments
 (0)