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 examples to docstrings #7937

Merged
merged 36 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
22540c7
xarray.dataset.equals
harshitha1201 Jun 23, 2023
dbada5e
xarray.dataset.identical
harshitha1201 Jun 23, 2023
2c65d00
xarray.dataset.broadcast_equals
harshitha1201 Jun 23, 2023
3323b44
minute_change
harshitha1201 Jun 27, 2023
c624473
assign_attrs
harshitha1201 Jul 3, 2023
d05092b
expand_dims
harshitha1201 Jul 7, 2023
75a492a
drop_vars
harshitha1201 Jul 7, 2023
9c3a0f7
equals
harshitha1201 Jul 7, 2023
39cdec8
broadcast.equals
harshitha1201 Jul 7, 2023
3cd3e93
identical
harshitha1201 Jul 7, 2023
5e8a7b8
Merge branch 'main' into add-examples3
harshitha1201 Jul 7, 2023
c4f236c
indentation
harshitha1201 Jul 7, 2023
dd35175
.
harshitha1201 Jul 7, 2023
ebe3f44
Merge branch 'main' into add-examples3
harshitha1201 Jul 11, 2023
c1b462d
.
harshitha1201 Jul 11, 2023
fa9468e
indentation
harshitha1201 Jul 12, 2023
24cf2e1
.
harshitha1201 Jul 12, 2023
4edce15
Merge branch 'main' into add-examples3
harshitha1201 Jul 12, 2023
5fd9421
what's new
harshitha1201 Jul 12, 2023
30a9280
.
harshitha1201 Jul 12, 2023
e66506b
.
harshitha1201 Jul 12, 2023
42d8468
.
harshitha1201 Jul 12, 2023
08e379d
.
harshitha1201 Jul 12, 2023
b0655aa
.
harshitha1201 Jul 12, 2023
8bddfde
.
harshitha1201 Jul 12, 2023
3dfe741
Merge branch 'main' into add-examples3
harshitha1201 Jul 13, 2023
479d79e
Try adding Traceback to doctest which raises error
TomNicholas Jul 14, 2023
50ec37d
Merge branch 'main' into add-examples3
harshitha1201 Jul 17, 2023
045a4f1
changing it intlo sub-heading
harshitha1201 Jul 17, 2023
95bb7f5
Merge branch 'add-examples3' of https://github.com/harshitha1201/xarr…
harshitha1201 Jul 17, 2023
3f07a68
what's new added
harshitha1201 Jul 17, 2023
9d54488
indentation error fixed
harshitha1201 Jul 17, 2023
04e3954
doctest
harshitha1201 Jul 17, 2023
3348ee7
Make possible raising of ValueError in drop_vars general
TomNicholas Jul 19, 2023
16213e3
Merge branch 'main' into add-examples3
TomNicholas Jul 19, 2023
c95b451
Merge branch 'main' into add-examples3
harshitha1201 Jul 25, 2023
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
6 changes: 3 additions & 3 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Bug fixes
Documentation
~~~~~~~~~~~~~

- Added examples to docstrings of :py:meth:`Dataset.tail`, :py:meth:`Dataset.head`, :py:meth:`Dataset.dropna`,
:py:meth:`Dataset.ffill`, :py:meth:`Dataset.bfill`, :py:meth:`Dataset.set_coords`, :py:meth:`Dataset.reset_coords`
(:issue:`6793`, :pull:`7936`) By `Harshitha <https://github.com/harshitha1201>`_ .
- Added examples to docstrings of :py:meth:`Dataset.assign_attrs`, :py:meth:`Dataset.broadcast_equals`,
:py:meth:`Dataset.equals`, :py:meth:`Dataset.identical`, :py:meth:`Dataset.expand_dims`,:py:meth:`Dataset.drop_vars`
(:issue:`6793`, :pull:`7937`) By `Harshitha <https://github.com/harshitha1201>`_.
- Added page on wrapping chunked numpy-like arrays as alternatives to dask arrays.
(:pull:`7951`) By `Tom Nicholas <https://github.com/TomNicholas>`_.
- Expanded the page on wrapping numpy-like "duck" arrays.
Expand Down
30 changes: 30 additions & 0 deletions xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,36 @@ def assign_attrs(
**kwargs
keyword arguments passed into ``attrs.update``.

Examples
harshitha1201 marked this conversation as resolved.
Show resolved Hide resolved
--------
>>> dataset = xr.Dataset({"temperature": [25, 30, 27]})
>>> dataset
<xarray.Dataset>
Dimensions: (temperature: 3)
Coordinates:
* temperature (temperature) int64 25 30 27
Data variables:
*empty*

>>> new_dataset = dataset.assign_attrs(
... units="Celsius", description="Temperature data"
... )
>>> new_dataset
<xarray.Dataset>
Dimensions: (temperature: 3)
Coordinates:
* temperature (temperature) int64 25 30 27
Data variables:
*empty*
Attributes:
units: Celsius
description: Temperature data

# Attributes of the new dataset

>>> new_dataset.attrs
{'units': 'Celsius', 'description': 'Temperature data'}

Returns
-------
assigned : same type as caller
Expand Down
Loading