Skip to content

Commit 87b2fd0

Browse files
authored
Better documentation of options (#6723)
1 parent cc18365 commit 87b2fd0

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

doc/user-guide/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ examples that describe many common tasks that you can accomplish with xarray.
2424
io
2525
dask
2626
plotting
27+
options
2728
duckarrays

doc/user-guide/options.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. currentmodule:: xarray
2+
3+
.. _options:
4+
5+
Configuration
6+
=============
7+
8+
Xarray offers a small number of configuration options through :py:func:`set_options`. With these, you can
9+
10+
1. Control the ``repr``:
11+
12+
- ``display_expand_attrs``
13+
- ``display_expand_coords``
14+
- ``display_expand_data``
15+
- ``display_expand_data_vars``
16+
- ``display_max_rows``
17+
- ``display_style``
18+
19+
2. Control behaviour during operations: ``arithmetic_join``, ``keep_attrs``, ``use_bottleneck``.
20+
3. Control colormaps for plots:``cmap_divergent``, ``cmap_sequential``.
21+
4. Aspects of file reading: ``file_cache_maxsize``, ``warn_on_unclosed_files``.
22+
23+
24+
You can set these options either globally
25+
26+
::
27+
28+
xr.set_options(arithmetic_join="exact")
29+
30+
or locally as a context manager:
31+
32+
::
33+
34+
with xr.set_options(arithmetic_join="exact"):
35+
# do operation here
36+
pass

xarray/core/options.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,18 @@ class set_options:
141141
Parameters
142142
----------
143143
arithmetic_join : {"inner", "outer", "left", "right", "exact"}, default: "inner"
144-
DataArray/Dataset alignment in binary operations.
144+
DataArray/Dataset alignment in binary operations:
145+
146+
- "outer": use the union of object indexes
147+
- "inner": use the intersection of object indexes
148+
- "left": use indexes from the first object with each dimension
149+
- "right": use indexes from the last object with each dimension
150+
- "exact": instead of aligning, raise `ValueError` when indexes to be
151+
aligned are not equal
152+
- "override": if indexes are of same size, rewrite indexes to be
153+
those of the first object with that dimension. Indexes for the same
154+
dimension must have the same size in all objects.
155+
145156
cmap_divergent : str or matplotlib.colors.Colormap, default: "RdBu_r"
146157
Colormap to use for divergent data plots. If string, must be
147158
matplotlib built-in colormap. Can also be a Colormap object

0 commit comments

Comments
 (0)