Skip to content

Doctest failures due to changes in xarray 2025.10 #4143

@seisman

Description

@seisman

From https://github.com/GenericMappingTools/pygmt/actions/runs/18328409327/job/52198267855, we have two failures in doctests:

=================================== FAILURES ===================================
_____________ [doctest] pygmt.datatypes.image._GMT_IMAGE.to_xarray _____________
109         --------
110         >>> from pygmt.clib import Session
111         >>> with Session() as lib:
112         ...     with lib.virtualfile_out(kind="image") as voutimg:
113         ...         lib.call_module("read", ["@earth_day_01d", voutimg, "-Ti"])
114         ...         # Read the image from the virtual file
115         ...         image = lib.read_virtualfile(voutimg, kind="image")
116         ...         # Convert to xarray.DataArray and use it later
117         ...         da = image.contents.to_xarray()
118         >>> da  # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
Differences (unified diff with -expected +actual):
    @@ -1,3 +1,3 @@
    -<xarray.DataArray 'z' (band: 3, y: 180, x: 360)>...
    +<xarray.DataArray 'z' (band: 3, y: 180, x: 360)> Size: 194kB
     array([[[ 10,  10,  10, ...,  10,  10,  10],
             [ 10,  10,  10, ...,  10,  10,  10],
    @@ -24,7 +24,7 @@
             [189, 191, 191, ..., 191, 191, 189]]], dtype=uint8)
     Coordinates:
    -  * y        (y) float64... 89.5 88.5 87.5 86.5 ... -86.5 -87.5 -88.5 -89.5
    -  * x        (x) float64... -179.5 -178.5 -177.5 -176.5 ... 177.5 178.5 179.5
    -  * band     (band) uint8... 1 2 3
    +  * band     (band) uint8 3B 1 2 3
    +  * y        (y) float64 1kB 89.5 88.5 87.5 86.5 ... -86.5 -87.5 -88.5 -89.5
    +  * x        (x) float64 3kB -179.5 -178.5 -177.5 -176.5 ... 177.5 178.5 179.5
     Attributes:
    -    long_name:     z
    +    long_name:  z

/home/runner/work/pygmt/pygmt/pygmt/datatypes/image.py:118: DocTestFailure
_____________ [doctest] pygmt.xarray.backend.GMTBackendEntrypoint ______________
057         description:   Reduced by Gaussian Cartesian filtering (111.2 km fullwidt...
058         actual_range:  [190. 981.]
059         long_name:     elevation (m)
060 
061     Read a multi-band GeoTIFF file using ``raster_kind="image"``
062 
063     >>> da_image = xr.open_dataarray(
064     ...     "@earth_night_01d", engine="gmt", raster_kind="image"
065     ... )
066     >>> da_image  # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
Differences (unified diff with -expected +actual):
    @@ -1,8 +1,8 @@
    -<xarray.DataArray 'z' (band: 3, y: 180, x: 360)>...
    +<xarray.DataArray 'z' (band: 3, y: 180, x: 360)> Size: 194kB
     [194400 values with dtype=uint8]
     Coordinates:
    -  * y        (y) float64... 89.5 88.5 87.5 86.5 ... -86.5 -87.5 -88.5 -89.5
    -  * x        (x) float64... -179.5 -178.5 -177.5 -176.5 ... 177.5 178.5 179.5
    -  * band     (band) uint8... 1 2 3
    -Attributes:...
    +  * band     (band) uint8 3B 1 2 3
    +  * y        (y) float64 1kB 89.5 88.5 87.5 86.5 ... -86.5 -87.5 -88.5 -89.5
    +  * x        (x) float64 3kB -179.5 -178.5 -177.5 -176.5 ... 177.5 178.5 179.5
    +Attributes:
         long_name:  z

These failures are caused by changes in pydata/xarray#10778.

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenanceBoring but important stuff for the core devs

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions