Skip to content
forked from pydata/xarray

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into kvikio-2
Browse files Browse the repository at this point in the history
* upstream/main: (46 commits)
  xfail flaky test (pydata#8299)
  Most of mypy 1.6.0 passing (pydata#8296)
  Rename `reset_encoding` to `drop_encoding` (pydata#8287)
  Enable `.rolling_exp` to work on dask arrays (pydata#8284)
  Fix `GroupBy` import (pydata#8286)
  Ask bug reporters to confirm they're using a recent version of xarray (pydata#8283)
  Add pyright type checker (pydata#8279)
  Improved typing of align & broadcast (pydata#8234)
  Update ci-additional.yaml (pydata#8280)
  Fix time encoding regression (pydata#8272)
  Allow a function in `.sortby` method (pydata#8273)
  make more args kw only (except 'dim') (pydata#6403)
  Use duck array ops in more places (pydata#8267)
  Don't raise rename warning if it is a no operation (pydata#8266)
  Mandate kwargs on `to_zarr` (pydata#8257)
  copy  the `dtypes` module to the `namedarray` package. (pydata#8250)
  Add xarray-regrid to ecosystem.rst (pydata#8270)
  Use strict type hinting for namedarray (pydata#8241)
  Update type annotation for center argument of dataaray_plot methods (pydata#8261)
  [pre-commit.ci] pre-commit autoupdate (pydata#8262)
  ...
  • Loading branch information
dcherian committed Oct 14, 2023
2 parents fe87c21 + 338fc92 commit 3d32187
Show file tree
Hide file tree
Showing 66 changed files with 3,663 additions and 2,287 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bugreport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ body:
- label: Complete example — the example is self-contained, including all data and the text of any traceback.
- label: Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.
- label: New issue — a search of GitHub Issues suggests this is not a duplicate.
- label: Recent environment — the issue occurs with the latest version of xarray and its dependencies.

- type: textarea
id: log-output
Expand Down
122 changes: 120 additions & 2 deletions .github/workflows/ci-additional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ jobs:
name: Mypy
runs-on: "ubuntu-latest"
needs: detect-ci-trigger
# temporarily skipping due to https://github.com/pydata/xarray/issues/6551
if: needs.detect-ci-trigger.outputs.triggered == 'false'
defaults:
run:
shell: bash -l {0}
Expand Down Expand Up @@ -190,6 +188,126 @@ jobs:



pyright:
name: Pyright
runs-on: "ubuntu-latest"
needs: detect-ci-trigger
if: |
always()
&& (
contains( github.event.pull_request.labels.*.name, 'run-pyright')
)
defaults:
run:
shell: bash -l {0}
env:
CONDA_ENV_FILE: ci/requirements/environment.yml
PYTHON_VERSION: "3.10"

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

- name: set environment variables
run: |
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Setup micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ${{env.CONDA_ENV_FILE}}
environment-name: xarray-tests
create-args: >-
python=${{env.PYTHON_VERSION}}
conda
cache-environment: true
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
- name: Install xarray
run: |
python -m pip install --no-deps -e .
- name: Version info
run: |
conda info -a
conda list
python xarray/util/print_versions.py
- name: Install pyright
run: |
python -m pip install pyright --force-reinstall
- name: Run pyright
run: |
python -m pyright xarray/
- name: Upload pyright coverage to Codecov
uses: codecov/[email protected]
with:
file: pyright_report/cobertura.xml
flags: pyright
env_vars: PYTHON_VERSION
name: codecov-umbrella
fail_ci_if_error: false

pyright39:
name: Pyright 3.9
runs-on: "ubuntu-latest"
needs: detect-ci-trigger
if: |
always()
&& (
contains( github.event.pull_request.labels.*.name, 'run-pyright')
)
defaults:
run:
shell: bash -l {0}
env:
CONDA_ENV_FILE: ci/requirements/environment.yml
PYTHON_VERSION: "3.9"

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

- name: set environment variables
run: |
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Setup micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ${{env.CONDA_ENV_FILE}}
environment-name: xarray-tests
create-args: >-
python=${{env.PYTHON_VERSION}}
conda
cache-environment: true
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
- name: Install xarray
run: |
python -m pip install --no-deps -e .
- name: Version info
run: |
conda info -a
conda list
python xarray/util/print_versions.py
- name: Install pyright
run: |
python -m pip install pyright --force-reinstall
- name: Run pyright
run: |
python -m pyright xarray/
- name: Upload pyright coverage to Codecov
uses: codecov/[email protected]
with:
file: pyright_report/cobertura.xml
flags: pyright39
env_vars: PYTHON_VERSION
name: codecov-umbrella
fail_ci_if_error: false



min-version-policy:
name: Minimum Version Policy
runs-on: "ubuntu-latest"
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ repos:
files: ^xarray/
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.287'
rev: 'v0.0.292'
hooks:
- id: ruff
args: ["--fix"]
# https://github.com/python/black#version-control-integration
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black-jupyter
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
hooks:
- id: blackdoc
exclude: "generate_aggregations.py"
additional_dependencies: ["black==23.7.0"]
additional_dependencies: ["black==23.9.1"]
- id: blackdoc-autoupdate-black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
Expand Down
13 changes: 11 additions & 2 deletions asv_bench/benchmarks/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from . import parameterized, randn, requires_dask

nx = 300
nx = 3000
long_nx = 30000
ny = 200
nt = 100
nt = 1000
window = 20

randn_xy = randn((nx, ny), frac_nan=0.1)
Expand Down Expand Up @@ -115,6 +115,11 @@ def peakmem_1drolling_reduce(self, func, use_bottleneck):
roll = self.ds.var3.rolling(t=100)
getattr(roll, func)()

@parameterized(["stride"], ([None, 5, 50]))
def peakmem_1drolling_construct(self, stride):
self.ds.var2.rolling(t=100).construct("w", stride=stride)
self.ds.var3.rolling(t=100).construct("w", stride=stride)


class DatasetRollingMemory(RollingMemory):
@parameterized(["func", "use_bottleneck"], (["sum", "max", "mean"], [True, False]))
Expand All @@ -128,3 +133,7 @@ def peakmem_1drolling_reduce(self, func, use_bottleneck):
with xr.set_options(use_bottleneck=use_bottleneck):
roll = self.ds.rolling(t=100)
getattr(roll, func)()

@parameterized(["stride"], ([None, 5, 50]))
def peakmem_1drolling_construct(self, stride):
self.ds.rolling(t=100).construct("w", stride=stride)
2 changes: 1 addition & 1 deletion doc/api-hidden.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
Variable.dims
Variable.dtype
Variable.encoding
Variable.reset_encoding
Variable.drop_encoding
Variable.imag
Variable.nbytes
Variable.ndim
Expand Down
4 changes: 2 additions & 2 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ Dataset contents
Dataset.drop_indexes
Dataset.drop_duplicates
Dataset.drop_dims
Dataset.drop_encoding
Dataset.set_coords
Dataset.reset_coords
Dataset.reset_encoding
Dataset.convert_calendar
Dataset.interp_calendar
Dataset.get_index
Expand Down Expand Up @@ -303,8 +303,8 @@ DataArray contents
DataArray.drop_vars
DataArray.drop_indexes
DataArray.drop_duplicates
DataArray.drop_encoding
DataArray.reset_coords
DataArray.reset_encoding
DataArray.copy
DataArray.convert_calendar
DataArray.interp_calendar
Expand Down
1 change: 1 addition & 0 deletions doc/ecosystem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Geosciences
harmonic wind analysis in Python.
- `wradlib <https://wradlib.org/>`_: An Open Source Library for Weather Radar Data Processing.
- `wrf-python <https://wrf-python.readthedocs.io/>`_: A collection of diagnostic and interpolation routines for use with output of the Weather Research and Forecasting (WRF-ARW) Model.
- `xarray-regrid <https://github.com/EXCITED-CO2/xarray-regrid>`_: xarray extension for regridding rectilinear data.
- `xarray-simlab <https://xarray-simlab.readthedocs.io>`_: xarray extension for computer model simulations.
- `xarray-spatial <https://xarray-spatial.org/>`_: Numba-accelerated raster-based spatial processing tools (NDVI, curvature, zonal-statistics, proximity, hillshading, viewshed, etc.)
- `xarray-topo <https://xarray-topo.readthedocs.io/>`_: xarray extension for topographic analysis and modelling.
Expand Down
6 changes: 3 additions & 3 deletions doc/user-guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,12 @@ Note that all operations that manipulate variables other than indexing
will remove encoding information.

In some cases it is useful to intentionally reset a dataset's original encoding values.
This can be done with either the :py:meth:`Dataset.reset_encoding` or
:py:meth:`DataArray.reset_encoding` methods.
This can be done with either the :py:meth:`Dataset.drop_encoding` or
:py:meth:`DataArray.drop_encoding` methods.

.. ipython:: python
ds_no_encoding = ds_disk.reset_encoding()
ds_no_encoding = ds_disk.drop_encoding()
ds_no_encoding.encoding
.. _combining multiple files:
Expand Down
Loading

0 comments on commit 3d32187

Please sign in to comment.