Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix doctest warnings, enable errors in CI #7166

Merged
merged 6 commits into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ci-additional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ jobs:
python xarray/util/print_versions.py
- name: Run doctests
run: |
python -m pytest --doctest-modules xarray --ignore xarray/tests
# Raise an error if there are warnings in the doctests, with `-Werror`.
# This is a trial; if it presents an problem, feel free to remove.
# See https://github.com/pydata/xarray/issues/7164 for more info.
python -m pytest --doctest-modules xarray --ignore xarray/tests -Werror
mypy:
name: Mypy
Expand Down
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Documentation

Internal Changes
~~~~~~~~~~~~~~~~
- Doctests fail on any warnings (:pull:`7166`)
By `Maximilian Roos <https://github.com/max-sixty>`_.



.. _whats-new.2022.10.0:
Expand Down
43 changes: 0 additions & 43 deletions xarray/backends/rasterio_.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,49 +187,6 @@ def open_rasterio(
<http://web.archive.org/web/20160326194152/http://remotesensing.org/geotiff/spec/geotiff2.5.html#2.5.2>`_
for more information).
You can generate 2D coordinates from the file's attributes with::
>>> from affine import Affine
>>> da = xr.open_rasterio(
... "https://github.com/rasterio/rasterio/raw/1.2.1/tests/data/RGB.byte.tif"
... )
>>> da
<xarray.DataArray (band: 3, y: 718, x: 791)>
[1703814 values with dtype=uint8]
Coordinates:
* band (band) int64 1 2 3
* y (y) float64 2.827e+06 2.826e+06 2.826e+06 ... 2.612e+06 2.612e+06
* x (x) float64 1.021e+05 1.024e+05 1.027e+05 ... 3.389e+05 3.392e+05
Attributes:
transform: (300.0379266750948, 0.0, 101985.0, 0.0, -300.041782729805...
crs: +init=epsg:32618
res: (300.0379266750948, 300.041782729805)
is_tiled: 0
nodatavals: (0.0, 0.0, 0.0)
scales: (1.0, 1.0, 1.0)
offsets: (0.0, 0.0, 0.0)
AREA_OR_POINT: Area
>>> transform = Affine(*da.attrs["transform"])
>>> transform
Affine(300.0379266750948, 0.0, 101985.0,
0.0, -300.041782729805, 2826915.0)
>>> nx, ny = da.sizes["x"], da.sizes["y"]
>>> x, y = transform * np.meshgrid(np.arange(nx) + 0.5, np.arange(ny) + 0.5)
>>> x
array([[102135.01896334, 102435.05689001, 102735.09481669, ...,
338564.90518331, 338864.94310999, 339164.98103666],
[102135.01896334, 102435.05689001, 102735.09481669, ...,
338564.90518331, 338864.94310999, 339164.98103666],
[102135.01896334, 102435.05689001, 102735.09481669, ...,
338564.90518331, 338864.94310999, 339164.98103666],
...,
[102135.01896334, 102435.05689001, 102735.09481669, ...,
338564.90518331, 338864.94310999, 339164.98103666],
[102135.01896334, 102435.05689001, 102735.09481669, ...,
338564.90518331, 338864.94310999, 339164.98103666],
[102135.01896334, 102435.05689001, 102735.09481669, ...,
338564.90518331, 338864.94310999, 339164.98103666]])
Parameters
----------
filename : str, rasterio.DatasetReader, or rasterio.WarpedVRT
Expand Down
18 changes: 6 additions & 12 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -5261,9 +5261,9 @@ def idxmin(
>>> array.min()
<xarray.DataArray ()>
array(-2)
>>> array.argmin()
<xarray.DataArray ()>
array(4)
>>> array.argmin(...)
{'x': <xarray.DataArray ()>
array(4)}
>>> array.idxmin()
<xarray.DataArray 'x' ()>
array('e', dtype='<U1')
Expand Down Expand Up @@ -5357,9 +5357,9 @@ def idxmax(
>>> array.max()
<xarray.DataArray ()>
array(2)
>>> array.argmax()
<xarray.DataArray ()>
array(1)
>>> array.argmax(...)
{'x': <xarray.DataArray ()>
array(1)}
>>> array.idxmax()
<xarray.DataArray 'x' ()>
array('b', dtype='<U1')
Expand Down Expand Up @@ -5450,9 +5450,6 @@ def argmin(
>>> array.min()
<xarray.DataArray ()>
array(-1)
>>> array.argmin()
<xarray.DataArray ()>
array(2)
>>> array.argmin(...)
{'x': <xarray.DataArray ()>
array(2)}
Expand Down Expand Up @@ -5555,9 +5552,6 @@ def argmax(
>>> array.max()
<xarray.DataArray ()>
array(3)
>>> array.argmax()
<xarray.DataArray ()>
array(3)
>>> array.argmax(...)
{'x': <xarray.DataArray ()>
array(3)}
Expand Down