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

Improve where docstring #3836

Merged
merged 5 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ Documentation
- Fix documentation of :py:class:`DataArray` removing the deprecated mention
that when omitted, `dims` are inferred from a `coords`-dict. (:pull:`3821`)
By `Sander van Rijn <https://github.com/sjvrijn>`_.
- Improve the :py:func:`where` docstring.
By `Maximilian Roos <https://github.com/max-sixty>`_
- Update the installation instructions: only explicitly list recommended dependencies
(:issue:`3756`).
By `Mathias Hauser <https://github.com/mathause>`_.
Expand Down
12 changes: 8 additions & 4 deletions xarray/core/computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,9 +1224,13 @@ def where(cond, x, y):
----------
cond : scalar, array, Variable, DataArray or Dataset with boolean dtype
When True, return values from `x`, otherwise returns values from `y`.
x, y : scalar, array, Variable, DataArray or Dataset
Values from which to choose. All dimension coordinates on these objects
must be aligned with each other and with `cond`.
x : scalar, array, Variable, DataArray or Dataset
values to choose from where `cond` is True
y : scalar, array, Variable, DataArray or Dataset
values to choose from where `cond` is False

All dimension coordinates on these objects must be aligned with each
other and with `cond`.

Returns
-------
Expand All @@ -1249,7 +1253,7 @@ def where(cond, x, y):
Coordinates:
* lat (lat) int64 0 1 2 3 4 5 6 7 8 9

>>> xr.where(x < 0.5, x, 100 * x)
>>> xr.where(x < 0.5, x, x * 100)
<xarray.DataArray 'sst' (lat: 10)>
array([ 0. , 0.1, 0.2, 0.3, 0.4, 50. , 60. , 70. , 80. , 90. ])
Coordinates:
Expand Down
2 changes: 0 additions & 2 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4390,8 +4390,6 @@ def assign(

Examples
--------
>>> import numpy as np
>>> import xarray as xr
>>> x = xr.Dataset(
... {
... "temperature_c": (
Expand Down