Skip to content

Doctest failing with numpy 2.1.3 #10005

@kmuehlbauer

Description

@kmuehlbauer

What happened?

Yesterday the doctest started to pull in numpy 2.1.3 (before 2.0.2) and NamedArray aggregations started to fail, returning a scalar instead of an array.

Working: https://github.com/pydata/xarray/actions/runs/13037739319/job/36372249466
Breaking: https://github.com/pydata/xarray/actions/runs/13044017287/job/36391424586

The same still works with DataArray returning an array.

That's a release blocker for #10002.

What did you expect to happen?

Doctest should run.

Minimal Complete Verifiable Example

import numpy as np
from xarray.namedarray.core import NamedArray
na = NamedArray("x", np.array([True, True, True, True, True, False], dtype=bool))
out = na.all()

MVCE confirmation

  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.
  • Recent environment — the issue occurs with the latest version of xarray and its dependencies.

Relevant log output

_____ [doctest] xarray.namedarray._aggregations.NamedArrayAggregations.all _____
113         --------
114         >>> from xarray.namedarray.core import NamedArray
115         >>> na = NamedArray(
116         ...     "x", np.array([True, True, True, True, True, False], dtype=bool)
117         ... )
118         >>> na
119         <xarray.NamedArray (x: 6)> Size: 6B
120         array([ True,  True,  True,  True,  True, False])
121 
122         >>> na.all()
Expected:
    <xarray.NamedArray ()> Size: 1B
    array(False)
Got:
    <xarray.NamedArray ()> Size: 1B
    np.False_

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS ------------------ commit: 151b89a python: 3.12.8 | packaged by conda-forge | (main, Dec 5 2024, 14:24:40) [GCC 13.3.0] python-bits: 64 OS: Linux OS-release: 6.8.0-1020-azure machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: C.UTF-8 LOCALE: ('C', 'UTF-8') libhdf5: 1.14.4 libnetcdf: 4.9.2

xarray: 2025.1.2.dev28+g151b89ac
pandas: 2.2.3
numpy: 2.1.3
scipy: 1.15.1
netCDF4: 1.7.2
pydap: 3.5.3
h5netcdf: 1.5.0
h5py: 3.12.1
zarr: 3.0.1
cftime: 1.6.4
nc_time_axis: 1.4.1
iris: 3.11.0
bottleneck: 1.4.2
dask: 2025.1.0
distributed: 2025.1.0
matplotlib: 3.10.0
cartopy: 0.24.0
seaborn: 0.13.2
numbagg: 0.8.2
fsspec: 2024.12.0
cupy: None
pint: None
sparse: 0.15.5
flox: 0.9.15
numpy_groupies: 0.11.2
setuptools: 75.8.0
pip: 25.0
conda: None
pytest: 8.3.4
mypy: None
IPython: None
sphinx: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions