Skip to content

Commit

Permalink
Add line break for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Ockenfuss committed Aug 24, 2024
1 parent 1626489 commit b3d70d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3570,6 +3570,7 @@ def interpolate_na(
>>> da = xr.DataArray(
... [np.nan, 2, 3, np.nan, 0], dims="x", coords={"x": [0, 1, 2, 3, 4]}
... )
>>> da
<xarray.DataArray (x: 5)> Size: 40B
array([nan, 2., 3., nan, 0.])
Expand Down Expand Up @@ -3888,28 +3889,32 @@ def fill_gaps(
... dims="x",
... coords={"x": [0, 1, 2, 3, 4, 5, 6]},
... )
>>> da
<xarray.DataArray (x: 7)> Size: 56B
array([nan, 2., nan, nan, 5., nan, 0.])
Coordinates:
* x (x) int64 56B 0 1 2 3 4 5 6
* x (x) int64 56B 0 1 2 3 4 5 6
>>> da.fill_gaps(dim="x", limit=1, limit_direction="forward").interpolate_na(
... dim="x"
... )
<xarray.DataArray (x: 7)> Size: 56B
array([nan, 2. , 3. , nan, 5. , 2.5, 0. ])
Coordinates:
* x (x) int64 56B 0 1 2 3 4 5 6
* x (x) int64 56B 0 1 2 3 4 5 6
>>> da.fill_gaps(dim="x", max_gap=2, limit_direction="forward").ffill(dim="x")
<xarray.DataArray (x: 7)> Size: 56B
array([nan, 2., nan, nan, 5., 5., 0.])
Coordinates:
* x (x) int64 56B 0 1 2 3 4 5 6
* x (x) int64 56B 0 1 2 3 4 5 6
>>> da.fill_gaps(dim="x", limit_area="inside").fillna(9)
<xarray.DataArray (x: 7)> Size: 56B
array([nan, 2., 9., 9., 5., 9., 0.])
Coordinates:
* x (x) int64 56B 0 1 2 3 4 5 6
* x (x) int64 56B 0 1 2 3 4 5 6
"""
from xarray.core.missing import mask_gaps

Expand Down
13 changes: 9 additions & 4 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6696,6 +6696,7 @@ def interpolate_na(
... },
... coords={"x": [0, 1, 2, 3, 4]},
... )
>>> ds
<xarray.Dataset> Size: 200B
Dimensions: (x: 5)
Expand Down Expand Up @@ -6998,37 +6999,41 @@ def fill_gaps(
... },
... coords={"x": [0, 1, 2, 3, 4, 5, 6]},
... )
>>> ds
<xarray.Dataset> Size: 168B
Dimensions: (x: 7)
Coordinates:
* x (x) int64 56B 0 1 2 3 4 5 6
* x (x) int64 56B 0 1 2 3 4 5 6
Data variables:
A (x) float64 56B nan 2.0 nan nan 5.0 nan 0.0
B (x) float64 56B nan 2.0 nan nan 5.0 6.0 nan
>>> ds.fill_gaps(dim="x", limit=1, limit_direction="forward").interpolate_na(
... dim="x"
... )
<xarray.Dataset> Size: 168B
Dimensions: (x: 7)
Coordinates:
* x (x) int64 56B 0 1 2 3 4 5 6
* x (x) int64 56B 0 1 2 3 4 5 6
Data variables:
A (x) float64 56B nan 2.0 3.0 nan 5.0 2.5 0.0
B (x) float64 56B nan 2.0 3.0 nan 5.0 6.0 nan
>>> ds.fill_gaps(dim="x", max_gap=2, limit_direction="forward").ffill(dim="x")
<xarray.Dataset> Size: 168B
Dimensions: (x: 7)
Coordinates:
* x (x) int64 56B 0 1 2 3 4 5 6
* x (x) int64 56B 0 1 2 3 4 5 6
Data variables:
A (x) float64 56B nan 2.0 nan nan 5.0 5.0 0.0
B (x) float64 56B nan 2.0 nan nan 5.0 6.0 6.0
>>> ds.fill_gaps(dim="x", limit_area="inside").fillna(9)
<xarray.Dataset> Size: 168B
Dimensions: (x: 7)
Coordinates:
* x (x) int64 56B 0 1 2 3 4 5 6
* x (x) int64 56B 0 1 2 3 4 5 6
Data variables:
A (x) float64 56B nan 2.0 9.0 9.0 5.0 9.0 0.0
B (x) float64 56B nan 2.0 9.0 9.0 5.0 6.0 nan
Expand Down

0 comments on commit b3d70d6

Please sign in to comment.