Skip to content

Commit 7897bca

Browse files
committed
doc: whats-new and coord_pad_mode usage in DataArray.pad
1 parent 3f72003 commit 7897bca

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

doc/whats-new.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ Bug Fixes
3939
By `Ian Hunt-Isaak <https://github.com/ianhi>`_
4040
- Coerce masked dask arrays to filled (:issue:`9374` :pull:`11157`).
4141
By `Julia Signell <https://github.com/jsignell>`_
42+
- Expose ``coord_pad_mode`` and associated parameters in ``Dataset.pad`` and
43+
``DataArray.pad`` (:issue:`3868` :issue:`6425` :pull:`11213`). By `Ian Cooke
44+
<https://github.com/ircwaves>`_.
4245

4346
Documentation
4447
~~~~~~~~~~~~~

xarray/core/dataarray.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5998,6 +5998,23 @@ def pad(
59985998
* x (x) float64 32B nan 0.0 1.0 nan
59995999
z (x) float64 32B nan 100.0 200.0 nan
60006000
* y (y) int64 32B 10 20 30 40
6001+
6002+
Note that the default behavior of coordinate padding uses NaNs (or NaTs), which
6003+
requires that integer types be promoted to floats. Providing values via
6004+
``coord_constant_values`` then follows the coercion behavior mentioned above,
6005+
where array types are preserved:
6006+
6007+
>>> da.pad(x=1, constant_values=1.23456789, coord_constant_values=-999.9)
6008+
<xarray.DataArray (x: 4, y: 4)> Size: 128B
6009+
array([[ 1, 1, 1, 1],
6010+
[ 0, 1, 2, 3],
6011+
[10, 11, 12, 13],
6012+
[ 1, 1, 1, 1]])
6013+
Coordinates:
6014+
* x (x) int64 32B -999 0 1 -999
6015+
z (x) int64 32B -999 100 200 -999
6016+
* y (y) int64 32B 10 20 30 40
6017+
60016018
"""
60026019
ds = self._to_temp_dataset().pad(
60036020
pad_width=pad_width,

0 commit comments

Comments
 (0)