Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation improvements #3328

Merged
merged 21 commits into from
Sep 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,17 +593,12 @@ def pipe(
temperature_c (lat, lon) float64 16.53 13.85 21.27 18.37
precipitation (lat, lon) float64 2.731 2.719 2.848 2.467

>>> x.pipe(adder, arg=2).pipe(div, arg=2)
<xarray.Dataset>
Dimensions: (lat: 2, lon: 2)
Coordinates:
* lon (lon) int64 150 160
* lat (lat) int64 10 20
Data variables:
temperature_c (lat, lon) float64 8.264 6.923 10.63 9.185
precipitation (lat, lon) float64 1.366 1.359 1.424 1.234

>>> x.pipe(adder, arg=2).pipe(div, arg=2).pipe(sub_mult, sub_arg=2, mult_arg=2)
>>> (
... x
... .pipe(adder, arg=2)
... .pipe(div, arg=2)
... .pipe(sub_mult, sub_arg=2, mult_arg=2)
... )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had written this in a rush—would you mind replacing with this? Then the formatting looks normal again. Apologies for the back & forth

(
    x
    .pipe(adder, arg=2)
    .pipe(adder, arg=4)
    .pipe(div, arg=2)
    .pipe(sub_mult, sub_arg=2, mult_arg=2)
)

<xarray.Dataset>
Dimensions: (lat: 2, lon: 2)
Coordinates:
Expand Down Expand Up @@ -1259,27 +1254,31 @@ def full_like(other, fill_value, dtype: DTypeLike = None):
Coordinates:
* lat (lat) int64 1 2
* lon (lon) int64 0 1 2

>>> xr.full_like(x, 1)
dcherian marked this conversation as resolved.
Show resolved Hide resolved
<xarray.DataArray (lat: 2, lon: 3)>
array([[1, 1, 1],
[1, 1, 1]])
Coordinates:
* lat (lat) int64 1 2
* lon (lon) int64 0 1 2

>>> xr.full_like(x, 0.5)
<xarray.DataArray (lat: 2, lon: 3)>
array([[0, 0, 0],
[0, 0, 0]])
Coordinates:
* lat (lat) int64 1 2
* lon (lon) int64 0 1 2

>>> xr.full_like(x, 0.5, dtype=np.double)
<xarray.DataArray (lat: 2, lon: 3)>
array([[0.5, 0.5, 0.5],
[0.5, 0.5, 0.5]])
Coordinates:
* lat (lat) int64 1 2
* lon (lon) int64 0 1 2

>>> xr.full_like(x, np.nan, dtype=np.double)
<xarray.DataArray (lat: 2, lon: 3)>
array([[nan, nan, nan],
Expand Down Expand Up @@ -1369,13 +1368,15 @@ def zeros_like(other, dtype: DTypeLike = None):
Coordinates:
* lat (lat) int64 1 2
* lon (lon) int64 0 1 2

>>> xr.zeros_like(x)
<xarray.DataArray (lat: 2, lon: 3)>
array([[0, 0, 0],
[0, 0, 0]])
Coordinates:
* lat (lat) int64 1 2
* lon (lon) int64 0 1 2

>>> xr.zeros_like(x, dtype=np.float)
<xarray.DataArray (lat: 2, lon: 3)>
array([[0., 0., 0.],
Expand Down Expand Up @@ -1425,6 +1426,7 @@ def ones_like(other, dtype: DTypeLike = None):
Coordinates:
* lat (lat) int64 1 2
* lon (lon) int64 0 1 2

>>> >>> xr.ones_like(x)
<xarray.DataArray (lat: 2, lon: 3)>
array([[1, 1, 1],
Expand Down
6 changes: 6 additions & 0 deletions xarray/core/computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,12 @@ def dot(*arrays, dims=None, **kwargs):
[10, 11]]])
andersy005 marked this conversation as resolved.
Show resolved Hide resolved
Dimensions without coordinates: a, b, c

>>> da_c
<xarray.DataArray (c: 2, d: 3)>
array([[0, 1, 2],
[3, 4, 5]])
Dimensions without coordinates: c, d

>>> xr.dot(da_a, da_b, dims=['a', 'b'])
<xarray.DataArray (c: 2)>
array([110, 125])
Expand Down