Skip to content

Commit

Permalink
Merge branch 'main' into pr/7948
Browse files Browse the repository at this point in the history
  • Loading branch information
Illviljan committed Sep 11, 2023
2 parents 463cf60 + cd6ba93 commit af27333
Show file tree
Hide file tree
Showing 53 changed files with 656 additions and 304 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks-last-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
# We need the full repo to avoid this issue
# https://github.com/actions/checkout/issues/23
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
# We need the full repo to avoid this issue
# https://github.com/actions/checkout/issues/23
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci-additional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
outputs:
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: xarray-contrib/ci-trigger@v1
Expand All @@ -44,7 +44,7 @@ jobs:
PYTHON_VERSION: "3.10"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.

Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
PYTHON_VERSION: "3.10"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.

Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
PYTHON_VERSION: "3.9"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.

Expand Down Expand Up @@ -205,7 +205,7 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
outputs:
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: xarray-contrib/ci-trigger@v1
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
python-version: "3.10"
os: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Set environment variables
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
if: github.repository == 'pydata/xarray'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
if: github.repository == 'pydata/xarray'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/upstream-dev-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
outputs:
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: xarray-contrib/ci-trigger@v1
Expand All @@ -52,7 +52,7 @@ jobs:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Set up conda environment
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Set up conda environment
Expand Down
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/dataset_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def time_read_dataset(self, engine, chunks):
class IOReadCustomEngine:
def setup(self, *args, **kwargs):
"""
The custom backend does the bare mininum to be considered a lazy backend. But
The custom backend does the bare minimum to be considered a lazy backend. But
the data in it is still in memory so slow file reading shouldn't affect the
results.
"""
Expand Down
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def setup(self, strategy, count):
data = np.array(["0", "b"], dtype=str)
self.dataset_coords = dict(time=np.array([0, 1]))
self.dataset_attrs = dict(description="Test data")
attrs = dict(units="Celcius")
attrs = dict(units="Celsius")
if strategy == "dict_of_DataArrays":

def create_data_vars():
Expand Down
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
"cftime": ("https://unidata.github.io/cftime", None),
"sparse": ("https://sparse.pydata.org/en/latest/", None),
"cubed": ("https://tom-e-white.com/cubed/", None),
"datatree": ("https://xarray-datatree.readthedocs.io/en/latest/", None),
}


Expand Down
2 changes: 1 addition & 1 deletion doc/internals/duck-arrays-integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Python Array API standard support
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

As an integration library xarray benefits greatly from the standardization of duck-array libraries' APIs, and so is a
big supporter of the `Python Array API Standard <https://data-apis.org/array-api/latest/>`_. .
big supporter of the `Python Array API Standard <https://data-apis.org/array-api/latest/>`_.

We aim to support any array libraries that follow the Array API standard out-of-the-box. However, xarray does occasionally
call some numpy functions which are not (yet) part of the standard (e.g. :py:meth:`xarray.DataArray.pad` calls :py:func:`numpy.pad`).
Expand Down
11 changes: 11 additions & 0 deletions doc/internals/extending-xarray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Xarray is designed as a general purpose library and hence tries to avoid
including overly domain specific functionality. But inevitably, the need for more
domain specific logic arises.

.. _internals.accessors.composition:

Composition over Inheritance
----------------------------

One potential solution to this problem is to subclass Dataset and/or DataArray to
add domain specific functionality. However, inheritance is not very robust. It's
easy to inadvertently use internal APIs when subclassing, which means that your
Expand All @@ -23,11 +28,17 @@ only return native xarray objects.
The standard advice is to use :issue:`composition over inheritance <706>`, but
reimplementing an API as large as xarray's on your own objects can be an onerous
task, even if most methods are only forwarding to xarray implementations.
(For an example of a project which took this approach of subclassing see `UXarray <https://github.com/UXARRAY/uxarray>`_).

If you simply want the ability to call a function with the syntax of a
method call, then the builtin :py:meth:`~xarray.DataArray.pipe` method (copied
from pandas) may suffice.

.. _internals.accessors.writing accessors:

Writing Custom Accessors
------------------------

To resolve this issue for more complex cases, xarray has the
:py:func:`~xarray.register_dataset_accessor` and
:py:func:`~xarray.register_dataarray_accessor` decorators for adding custom
Expand Down
9 changes: 4 additions & 5 deletions doc/internals/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _internals:

xarray Internals
Xarray Internals
================

Xarray builds upon two of the foundational libraries of the scientific Python
Expand All @@ -11,15 +11,14 @@ compiled code to :ref:`optional dependencies<installing>`.
The pages in this section are intended for:

* Contributors to xarray who wish to better understand some of the internals,
* Developers who wish to extend xarray with domain-specific logic, perhaps to support a new scientific community of users,
* Developers who wish to interface xarray with their existing tooling, e.g. by creating a plugin for reading a new file format, or wrapping a custom array type.

* Developers from other fields who wish to extend xarray with domain-specific logic, perhaps to support a new scientific community of users,
* Developers of other packages who wish to interface xarray with their existing tools, e.g. by creating a backend for reading a new file format, or wrapping a custom array type.

.. toctree::
:maxdepth: 2
:hidden:

variable-objects
internal-design
duck-arrays-integration
chunked-arrays
extending-xarray
Expand Down
Loading

0 comments on commit af27333

Please sign in to comment.