From 6faafd8f15fa83d3e15f03f9d8a3cd608acbd11c Mon Sep 17 00:00:00 2001 From: C1-BA-B1-F3 Date: Fri, 26 Jun 2026 21:43:33 +0800 Subject: [PATCH] Fix incorrect default value for constant_values in DataArray.pad docs The docstring for DataArray.pad incorrectly stated that constant_values defaults to 0. The actual default is None, which results in NaN padding (see Variable.pad implementation). Updated to match the Dataset.pad docstring which already correctly documents this behavior. Fixes #11373 --- xarray/core/dataarray.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index fc8edb1473c..6d272253a0c 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -5912,7 +5912,7 @@ def pad( (stat_length,) or int is a shortcut for before = after = statistic length for all axes. Default is ``None``, to use the entire axis. - constant_values : scalar, tuple or mapping of Hashable to tuple, default: 0 + constant_values : scalar, tuple or mapping of Hashable to tuple, default: None Used in 'constant'. The values to set the padded values for each axis. ``{dim_1: (before_1, after_1), ... dim_N: (before_N, after_N)}`` unique @@ -5921,7 +5921,7 @@ def pad( dimension. ``(constant,)`` or ``constant`` is a shortcut for ``before = after = constant`` for all dimensions. - Default is 0. + Default is ``None``, pads with ``np.nan``. end_values : scalar, tuple or mapping of Hashable to tuple, default: 0 Used in 'linear_ramp'. The values used for the ending value of the linear_ramp and that will form the edge of the padded array.