Skip to content

Commit e26aec9

Browse files
authored
Move docstring for xr.set_options to numpy style (#5702)
* Move docstring to numpy style * Update options.py * Update options.py
1 parent 3cc3ab1 commit e26aec9

File tree

1 file changed

+69
-51
lines changed

1 file changed

+69
-51
lines changed

xarray/core/options.py

+69-51
Original file line numberDiff line numberDiff line change
@@ -151,57 +151,75 @@ def _get_keep_attrs(default):
151151

152152

153153
class set_options:
154-
"""Set options for xarray in a controlled context.
155-
156-
Currently supported options:
157-
158-
- ``display_width``: maximum display width for ``repr`` on xarray objects.
159-
Default: ``80``.
160-
- ``display_max_rows``: maximum display rows. Default: ``12``.
161-
- ``arithmetic_join``: DataArray/Dataset alignment in binary operations.
162-
Default: ``'inner'``.
163-
- ``file_cache_maxsize``: maximum number of open files to hold in xarray's
164-
global least-recently-usage cached. This should be smaller than your
165-
system's per-process file descriptor limit, e.g., ``ulimit -n`` on Linux.
166-
Default: 128.
167-
- ``warn_for_unclosed_files``: whether or not to issue a warning when
168-
unclosed files are deallocated (default False). This is mostly useful
169-
for debugging.
170-
- ``cmap_sequential``: colormap to use for nondivergent data plots.
171-
Default: ``viridis``. If string, must be matplotlib built-in colormap.
172-
Can also be a Colormap object (e.g. mpl.cm.magma)
173-
- ``cmap_divergent``: colormap to use for divergent data plots.
174-
Default: ``RdBu_r``. If string, must be matplotlib built-in colormap.
175-
Can also be a Colormap object (e.g. mpl.cm.magma)
176-
- ``keep_attrs``: rule for whether to keep attributes on xarray
177-
Datasets/dataarrays after operations. Either ``True`` to always keep
178-
attrs, ``False`` to always discard them, or ``'default'`` to use original
179-
logic that attrs should only be kept in unambiguous circumstances.
180-
Default: ``'default'``.
181-
- ``use_bottleneck``: allow using bottleneck. Either ``True`` to accelerate
182-
operations using bottleneck if it is installed or ``False`` to never use it.
183-
Default: ``True``
184-
- ``display_style``: display style to use in jupyter for xarray objects.
185-
Default: ``'html'``. Other options are ``'text'``.
186-
- ``display_expand_attrs``: whether to expand the attributes section for
187-
display of ``DataArray`` or ``Dataset`` objects. Can be ``True`` to always
188-
expand, ``False`` to always collapse, or ``default`` to expand unless over
189-
a pre-defined limit. Default: ``default``.
190-
- ``display_expand_coords``: whether to expand the coordinates section for
191-
display of ``DataArray`` or ``Dataset`` objects. Can be ``True`` to always
192-
expand, ``False`` to always collapse, or ``default`` to expand unless over
193-
a pre-defined limit. Default: ``default``.
194-
- ``display_expand_data``: whether to expand the data section for display
195-
of ``DataArray`` objects. Can be ``True`` to always expand, ``False`` to
196-
always collapse, or ``default`` to expand unless over a pre-defined limit.
197-
Default: ``default``.
198-
- ``display_expand_data_vars``: whether to expand the data variables section
199-
for display of ``Dataset`` objects. Can be ``True`` to always
200-
expand, ``False`` to always collapse, or ``default`` to expand unless over
201-
a pre-defined limit. Default: ``default``.
202-
203-
204-
You can use ``set_options`` either as a context manager:
154+
"""
155+
Set options for xarray in a controlled context.
156+
157+
Parameters
158+
----------
159+
display_width : int, default: 80
160+
Maximum display width for ``repr`` on xarray objects.
161+
display_max_rows : int, default: 12
162+
Maximum display rows.
163+
arithmetic_join : {"inner", "outer", "left", "right", "exact"}
164+
DataArray/Dataset alignment in binary operations.
165+
file_cache_maxsize : int, default: 128
166+
Maximum number of open files to hold in xarray's
167+
global least-recently-usage cached. This should be smaller than
168+
your system's per-process file descriptor limit, e.g.,
169+
``ulimit -n`` on Linux.
170+
warn_for_unclosed_files : bool, default: False
171+
Whether or not to issue a warning when unclosed files are
172+
deallocated. This is mostly useful for debugging.
173+
cmap_sequential : str or matplotlib.colors.Colormap, default: "viridis"
174+
Colormap to use for nondivergent data plots. If string, must be
175+
matplotlib built-in colormap. Can also be a Colormap object
176+
(e.g. mpl.cm.magma)
177+
cmap_divergent : str or matplotlib.colors.Colormap, default: "RdBu_r"
178+
Colormap to use for divergent data plots. If string, must be
179+
matplotlib built-in colormap. Can also be a Colormap object
180+
(e.g. mpl.cm.magma)
181+
keep_attrs : {"default", True, False}
182+
Whether to keep attributes on xarray Datasets/dataarrays after
183+
operations. Can be
184+
185+
* ``True`` : to always keep attrs
186+
* ``False`` : to always discard attrs
187+
* ``default`` : to use original logic that attrs should only
188+
be kept in unambiguous circumstances
189+
display_style : {"text", "html"}
190+
Display style to use in jupyter for xarray objects.
191+
display_expand_attrs : {"default", True, False}:
192+
Whether to expand the attributes section for display of
193+
``DataArray`` or ``Dataset`` objects. Can be
194+
195+
* ``True`` : to always expand attrs
196+
* ``False`` : to always collapse attrs
197+
* ``default`` : to expand unless over a pre-defined limit
198+
display_expand_coords : {"default", True, False}:
199+
Whether to expand the coordinates section for display of
200+
``DataArray`` or ``Dataset`` objects. Can be
201+
202+
* ``True`` : to always expand coordinates
203+
* ``False`` : to always collapse coordinates
204+
* ``default`` : to expand unless over a pre-defined limit
205+
display_expand_data : {"default", True, False}:
206+
Whether to expand the data section for display of ``DataArray``
207+
objects. Can be
208+
209+
* ``True`` : to always expand data
210+
* ``False`` : to always collapse data
211+
* ``default`` : to expand unless over a pre-defined limit
212+
display_expand_data_vars : {"default", True, False}:
213+
Whether to expand the data variables section for display of
214+
``Dataset`` objects. Can be
215+
216+
* ``True`` : to always expand data variables
217+
* ``False`` : to always collapse data variables
218+
* ``default`` : to expand unless over a pre-defined limit
219+
220+
Examples
221+
--------
222+
It is possible to use ``set_options`` either as a context manager:
205223
206224
>>> ds = xr.Dataset({"x": np.arange(1000)})
207225
>>> with xr.set_options(display_width=40):

0 commit comments

Comments
 (0)