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

Add cross-links to API docstring from tutorial and user-guide #8311

Merged
merged 9 commits into from
Nov 5, 2023
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
]
)

nbsphinx_allow_errors = False
nbsphinx_allow_errors = True
amanbagrecha marked this conversation as resolved.
Show resolved Hide resolved

# -- General configuration ------------------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions xarray/core/computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,9 +1141,13 @@ def apply_ufunc(
numba.guvectorize
dask.array.apply_gufunc
xarray.map_blocks

:ref:`dask.automatic-parallelization`
User guide describing :py:func:`apply_ufunc` and :py:func:`map_blocks`.

`Tutorial on apply_ufunc <https://tutorial.xarray.dev/advanced/apply_ufunc/apply_ufunc.html>`_
Advanced Tutorial on applying numpy function using :py:func:`apply_ufunc`

References
----------
.. [1] https://numpy.org/doc/stable/reference/ufuncs.html
Expand Down
30 changes: 30 additions & 0 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -5435,6 +5435,9 @@ def map_blocks(
dask.array.map_blocks, xarray.apply_ufunc, xarray.Dataset.map_blocks
xarray.DataArray.map_blocks

`**Tutorial on map_blocks** <https://tutorial.xarray.dev/advanced/map_blocks/map_blocks.html>`_
Advanced Tutorial on map_blocks with dask

Examples
--------
Calculate an anomaly from climatology using ``.groupby()``. Using
Expand Down Expand Up @@ -6650,10 +6653,20 @@ def groupby(
--------
:ref:`groupby`
Users guide explanation of how to group and bin data.

`Deconstructing GroupBy operation <https://tutorial.xarray.dev/intermediate/01-high-level-computation-patterns.html#label-space-windows-or-bins-groupby>`_
Tutorial on :py:func:`~xarray.DataArray.Groupby` for windowed computation

`Grouped Computation <https://tutorial.xarray.dev/fundamentals/03.2_groupby_with_xarray.html>`_
Tutorial on :py:func:`~xarray.DataArray.Groupby` demonstrating reductions, transformation and comparison with :py:func:`~xarray.DataArray.resample`

DataArray.groupby_bins
Dataset.groupby
core.groupby.DataArrayGroupBy
DataArray.coarsen
pandas.DataFrame.groupby
Dataset.resample
DataArray.resample
"""
from xarray.core.groupby import (
DataArrayGroupBy,
Expand Down Expand Up @@ -6788,6 +6801,13 @@ def weighted(self, weights: DataArray) -> DataArrayWeighted:
See Also
--------
Dataset.weighted

`Weighted array reductions <https://docs.xarray.dev/en/stable/user-guide/computation.html#weighted-array-reductions>`_
Copy link
Collaborator

@keewis keewis Oct 22, 2023

Choose a reason for hiding this comment

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

you can use sphobjinv su -u https://docs.xarray.dev/en/latest computation to find the appropriate link, in this case

:std:label:`/user-guide/computation.rst#weighted-array-reductions`

(though maybe we need to add label directives to user-guide/computation to make this easier? E.g. add

.. _weighted-array-reductions:

just before that section... not sure if - is a allowed character in labels, though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

many thanks! I made the necessary changes.

User guide on weighted array reduction using :py:func:`~xarray.DataArray.weighted`

`Weighted reduction <https://tutorial.xarray.dev/fundamentals/03.4_weighted.html>`_
Tutorial on Weighted Reduction using :py:func:`~xarray.DataArray.weighted`

"""
from xarray.core.weighted import DataArrayWeighted

Expand Down Expand Up @@ -6929,6 +6949,16 @@ def coarsen(
--------
core.rolling.DataArrayCoarsen
Dataset.coarsen

`Reshaping via coarsen <https://docs.xarray.dev/en/stable/user-guide/reshaping.html#reshaping-via-coarsen>`_
User guide describing :py:func:`~xarray.DataArray.coarsen`

`Coarsening large arrays <https://docs.xarray.dev/en/stable/user-guide/computation.html#coarsen-large-arrays>`_
User guide on block arrgragation :py:func:`~xarray.DataArray.coarsen`

`Block window operation and reshaping <https://tutorial.xarray.dev/fundamentals/03.3_windowed.html?#coarsening>`_
Tutorial on windowed computation using :py:func:`~xarray.DataArray.coarsen`

"""
from xarray.core.rolling import DataArrayCoarsen

Expand Down
35 changes: 35 additions & 0 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2889,6 +2889,12 @@ def isel(
--------
Dataset.sel
DataArray.isel


`**Tutorial on indexing** <https://tutorial.xarray.dev/intermediate/indexing/indexing.html>`_
Tutorial material on indexing with Xarray objects


"""
indexers = either_dict_or_kwargs(indexers, indexers_kwargs, "isel")
if any(is_fancy_indexer(idx) for idx in indexers.values()):
Expand Down Expand Up @@ -8633,6 +8639,10 @@ def map_blocks(
dask.array.map_blocks, xarray.apply_ufunc, xarray.Dataset.map_blocks
xarray.DataArray.map_blocks

`**Tutorial on map_blocks** <https://tutorial.xarray.dev/advanced/map_blocks/map_blocks.html>`_
Advanced Tutorial on map_blocks with dask


Examples
--------
Calculate an anomaly from climatology using ``.groupby()``. Using
Expand Down Expand Up @@ -10018,10 +10028,18 @@ def groupby(
--------
:ref:`groupby`
Users guide explanation of how to group and bin data.

`Deconstructing GroupBy operation <https://tutorial.xarray.dev/intermediate/01-high-level-computation-patterns.html#label-space-windows-or-bins-groupby>`_
Tutorial on :py:func:`~xarray.Dataset.Groupby` for windowed computation.

`Grouped Computation <https://tutorial.xarray.dev/fundamentals/03.2_groupby_with_xarray.html>`_
Tutorial on :py:func:`~xarray.Dataset.Groupby` demonstrating reductions, transformation and comparision with :py:func:`~xarray.Dataset.resample`.

Dataset.groupby_bins
DataArray.groupby
core.groupby.DatasetGroupBy
pandas.DataFrame.groupby
Dataset.coarsen
Dataset.resample
DataArray.resample
"""
Expand Down Expand Up @@ -10159,6 +10177,13 @@ def weighted(self, weights: DataArray) -> DatasetWeighted:
See Also
--------
DataArray.weighted

`Weighted array reductions <https://docs.xarray.dev/en/stable/user-guide/computation.html#weighted-array-reductions>`_
User guide on weighted array reduction using :py:func:`~xarray.Dataset.weighted`

`Weighted reduction <https://tutorial.xarray.dev/fundamentals/03.4_weighted.html>`_
Tutorial on Weighted Reduction using :py:func:`~xarray.Dataset.weighted`

"""
from xarray.core.weighted import DatasetWeighted

Expand Down Expand Up @@ -10235,6 +10260,16 @@ def coarsen(
--------
core.rolling.DatasetCoarsen
DataArray.coarsen

`Understanding reshaping via coarsen <https://docs.xarray.dev/en/stable/user-guide/reshaping.html#reshaping-via-coarsen>`_
User guide describing :py:func:`~xarray.Dataset.coarsen`

`Coarsening large arrays <https://docs.xarray.dev/en/stable/user-guide/computation.html#coarsen-large-arrays>`_
User guide on block arrgragation :py:func:`~xarray.Dataset.coarsen`

`Block window operation and reshaping <https://tutorial.xarray.dev/fundamentals/03.3_windowed.html?#coarsening>`_
Tutorial on windowed computation using :py:func:`~xarray.Dataset.coarsen`

"""
from xarray.core.rolling import DatasetCoarsen

Expand Down
1 change: 1 addition & 0 deletions xarray/core/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ def __init__(
Returns
-------
coarsen

"""
self.obj = obj
self.windows = windows
Expand Down
Loading