Skip to content

Commit 3d32187

Browse files
committed
Merge remote-tracking branch 'upstream/main' into kvikio-2
* upstream/main: (46 commits) xfail flaky test (#8299) Most of mypy 1.6.0 passing (#8296) Rename `reset_encoding` to `drop_encoding` (#8287) Enable `.rolling_exp` to work on dask arrays (#8284) Fix `GroupBy` import (#8286) Ask bug reporters to confirm they're using a recent version of xarray (#8283) Add pyright type checker (#8279) Improved typing of align & broadcast (#8234) Update ci-additional.yaml (#8280) Fix time encoding regression (#8272) Allow a function in `.sortby` method (#8273) make more args kw only (except 'dim') (#6403) Use duck array ops in more places (#8267) Don't raise rename warning if it is a no operation (#8266) Mandate kwargs on `to_zarr` (#8257) copy the `dtypes` module to the `namedarray` package. (#8250) Add xarray-regrid to ecosystem.rst (#8270) Use strict type hinting for namedarray (#8241) Update type annotation for center argument of dataaray_plot methods (#8261) [pre-commit.ci] pre-commit autoupdate (#8262) ...
2 parents fe87c21 + 338fc92 commit 3d32187

Some content is hidden

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

66 files changed

+3663
-2287
lines changed

.github/ISSUE_TEMPLATE/bugreport.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ body:
4444
- label: Complete example — the example is self-contained, including all data and the text of any traceback.
4545
- 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.
4646
- label: New issue — a search of GitHub Issues suggests this is not a duplicate.
47+
- label: Recent environment — the issue occurs with the latest version of xarray and its dependencies.
4748

4849
- type: textarea
4950
id: log-output

.github/workflows/ci-additional.yaml

Lines changed: 120 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ jobs:
8282
name: Mypy
8383
runs-on: "ubuntu-latest"
8484
needs: detect-ci-trigger
85-
# temporarily skipping due to https://github.com/pydata/xarray/issues/6551
86-
if: needs.detect-ci-trigger.outputs.triggered == 'false'
8785
defaults:
8886
run:
8987
shell: bash -l {0}
@@ -190,6 +188,126 @@ jobs:
190188

191189

192190

191+
pyright:
192+
name: Pyright
193+
runs-on: "ubuntu-latest"
194+
needs: detect-ci-trigger
195+
if: |
196+
always()
197+
&& (
198+
contains( github.event.pull_request.labels.*.name, 'run-pyright')
199+
)
200+
defaults:
201+
run:
202+
shell: bash -l {0}
203+
env:
204+
CONDA_ENV_FILE: ci/requirements/environment.yml
205+
PYTHON_VERSION: "3.10"
206+
207+
steps:
208+
- uses: actions/checkout@v4
209+
with:
210+
fetch-depth: 0 # Fetch all history for all branches and tags.
211+
212+
- name: set environment variables
213+
run: |
214+
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
215+
- name: Setup micromamba
216+
uses: mamba-org/setup-micromamba@v1
217+
with:
218+
environment-file: ${{env.CONDA_ENV_FILE}}
219+
environment-name: xarray-tests
220+
create-args: >-
221+
python=${{env.PYTHON_VERSION}}
222+
conda
223+
cache-environment: true
224+
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
225+
- name: Install xarray
226+
run: |
227+
python -m pip install --no-deps -e .
228+
- name: Version info
229+
run: |
230+
conda info -a
231+
conda list
232+
python xarray/util/print_versions.py
233+
- name: Install pyright
234+
run: |
235+
python -m pip install pyright --force-reinstall
236+
237+
- name: Run pyright
238+
run: |
239+
python -m pyright xarray/
240+
241+
- name: Upload pyright coverage to Codecov
242+
uses: codecov/[email protected]
243+
with:
244+
file: pyright_report/cobertura.xml
245+
flags: pyright
246+
env_vars: PYTHON_VERSION
247+
name: codecov-umbrella
248+
fail_ci_if_error: false
249+
250+
pyright39:
251+
name: Pyright 3.9
252+
runs-on: "ubuntu-latest"
253+
needs: detect-ci-trigger
254+
if: |
255+
always()
256+
&& (
257+
contains( github.event.pull_request.labels.*.name, 'run-pyright')
258+
)
259+
defaults:
260+
run:
261+
shell: bash -l {0}
262+
env:
263+
CONDA_ENV_FILE: ci/requirements/environment.yml
264+
PYTHON_VERSION: "3.9"
265+
266+
steps:
267+
- uses: actions/checkout@v4
268+
with:
269+
fetch-depth: 0 # Fetch all history for all branches and tags.
270+
271+
- name: set environment variables
272+
run: |
273+
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
274+
- name: Setup micromamba
275+
uses: mamba-org/setup-micromamba@v1
276+
with:
277+
environment-file: ${{env.CONDA_ENV_FILE}}
278+
environment-name: xarray-tests
279+
create-args: >-
280+
python=${{env.PYTHON_VERSION}}
281+
conda
282+
cache-environment: true
283+
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
284+
- name: Install xarray
285+
run: |
286+
python -m pip install --no-deps -e .
287+
- name: Version info
288+
run: |
289+
conda info -a
290+
conda list
291+
python xarray/util/print_versions.py
292+
- name: Install pyright
293+
run: |
294+
python -m pip install pyright --force-reinstall
295+
296+
- name: Run pyright
297+
run: |
298+
python -m pyright xarray/
299+
300+
- name: Upload pyright coverage to Codecov
301+
uses: codecov/[email protected]
302+
with:
303+
file: pyright_report/cobertura.xml
304+
flags: pyright39
305+
env_vars: PYTHON_VERSION
306+
name: codecov-umbrella
307+
fail_ci_if_error: false
308+
309+
310+
193311
min-version-policy:
194312
name: Minimum Version Policy
195313
runs-on: "ubuntu-latest"

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ repos:
1818
files: ^xarray/
1919
- repo: https://github.com/astral-sh/ruff-pre-commit
2020
# Ruff version.
21-
rev: 'v0.0.287'
21+
rev: 'v0.0.292'
2222
hooks:
2323
- id: ruff
2424
args: ["--fix"]
2525
# https://github.com/python/black#version-control-integration
2626
- repo: https://github.com/psf/black
27-
rev: 23.7.0
27+
rev: 23.9.1
2828
hooks:
2929
- id: black-jupyter
3030
- repo: https://github.com/keewis/blackdoc
3131
rev: v0.3.8
3232
hooks:
3333
- id: blackdoc
3434
exclude: "generate_aggregations.py"
35-
additional_dependencies: ["black==23.7.0"]
35+
additional_dependencies: ["black==23.9.1"]
3636
- id: blackdoc-autoupdate-black
3737
- repo: https://github.com/pre-commit/mirrors-mypy
3838
rev: v1.5.1

asv_bench/benchmarks/rolling.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
from . import parameterized, randn, requires_dask
77

8-
nx = 300
8+
nx = 3000
99
long_nx = 30000
1010
ny = 200
11-
nt = 100
11+
nt = 1000
1212
window = 20
1313

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

118+
@parameterized(["stride"], ([None, 5, 50]))
119+
def peakmem_1drolling_construct(self, stride):
120+
self.ds.var2.rolling(t=100).construct("w", stride=stride)
121+
self.ds.var3.rolling(t=100).construct("w", stride=stride)
122+
118123

119124
class DatasetRollingMemory(RollingMemory):
120125
@parameterized(["func", "use_bottleneck"], (["sum", "max", "mean"], [True, False]))
@@ -128,3 +133,7 @@ def peakmem_1drolling_reduce(self, func, use_bottleneck):
128133
with xr.set_options(use_bottleneck=use_bottleneck):
129134
roll = self.ds.rolling(t=100)
130135
getattr(roll, func)()
136+
137+
@parameterized(["stride"], ([None, 5, 50]))
138+
def peakmem_1drolling_construct(self, stride):
139+
self.ds.rolling(t=100).construct("w", stride=stride)

doc/api-hidden.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@
265265
Variable.dims
266266
Variable.dtype
267267
Variable.encoding
268-
Variable.reset_encoding
268+
Variable.drop_encoding
269269
Variable.imag
270270
Variable.nbytes
271271
Variable.ndim

doc/api.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ Dataset contents
110110
Dataset.drop_indexes
111111
Dataset.drop_duplicates
112112
Dataset.drop_dims
113+
Dataset.drop_encoding
113114
Dataset.set_coords
114115
Dataset.reset_coords
115-
Dataset.reset_encoding
116116
Dataset.convert_calendar
117117
Dataset.interp_calendar
118118
Dataset.get_index
@@ -303,8 +303,8 @@ DataArray contents
303303
DataArray.drop_vars
304304
DataArray.drop_indexes
305305
DataArray.drop_duplicates
306+
DataArray.drop_encoding
306307
DataArray.reset_coords
307-
DataArray.reset_encoding
308308
DataArray.copy
309309
DataArray.convert_calendar
310310
DataArray.interp_calendar

doc/ecosystem.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Geosciences
4141
harmonic wind analysis in Python.
4242
- `wradlib <https://wradlib.org/>`_: An Open Source Library for Weather Radar Data Processing.
4343
- `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.
44+
- `xarray-regrid <https://github.com/EXCITED-CO2/xarray-regrid>`_: xarray extension for regridding rectilinear data.
4445
- `xarray-simlab <https://xarray-simlab.readthedocs.io>`_: xarray extension for computer model simulations.
4546
- `xarray-spatial <https://xarray-spatial.org/>`_: Numba-accelerated raster-based spatial processing tools (NDVI, curvature, zonal-statistics, proximity, hillshading, viewshed, etc.)
4647
- `xarray-topo <https://xarray-topo.readthedocs.io/>`_: xarray extension for topographic analysis and modelling.

doc/user-guide/io.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,12 @@ Note that all operations that manipulate variables other than indexing
260260
will remove encoding information.
261261

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

266266
.. ipython:: python
267267
268-
ds_no_encoding = ds_disk.reset_encoding()
268+
ds_no_encoding = ds_disk.drop_encoding()
269269
ds_no_encoding.encoding
270270
271271
.. _combining multiple files:

0 commit comments

Comments
 (0)