Skip to content

Commit

Permalink
Better documentation of options (pydata#6723)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian authored Jun 25, 2022
1 parent cc18365 commit 87b2fd0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/user-guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ examples that describe many common tasks that you can accomplish with xarray.
io
dask
plotting
options
duckarrays
36 changes: 36 additions & 0 deletions doc/user-guide/options.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. currentmodule:: xarray

.. _options:

Configuration
=============

Xarray offers a small number of configuration options through :py:func:`set_options`. With these, you can

1. Control the ``repr``:

- ``display_expand_attrs``
- ``display_expand_coords``
- ``display_expand_data``
- ``display_expand_data_vars``
- ``display_max_rows``
- ``display_style``

2. Control behaviour during operations: ``arithmetic_join``, ``keep_attrs``, ``use_bottleneck``.
3. Control colormaps for plots:``cmap_divergent``, ``cmap_sequential``.
4. Aspects of file reading: ``file_cache_maxsize``, ``warn_on_unclosed_files``.


You can set these options either globally

::

xr.set_options(arithmetic_join="exact")

or locally as a context manager:

::

with xr.set_options(arithmetic_join="exact"):
# do operation here
pass
13 changes: 12 additions & 1 deletion xarray/core/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,18 @@ class set_options:
Parameters
----------
arithmetic_join : {"inner", "outer", "left", "right", "exact"}, default: "inner"
DataArray/Dataset alignment in binary operations.
DataArray/Dataset alignment in binary operations:
- "outer": use the union of object indexes
- "inner": use the intersection of object indexes
- "left": use indexes from the first object with each dimension
- "right": use indexes from the last object with each dimension
- "exact": instead of aligning, raise `ValueError` when indexes to be
aligned are not equal
- "override": if indexes are of same size, rewrite indexes to be
those of the first object with that dimension. Indexes for the same
dimension must have the same size in all objects.
cmap_divergent : str or matplotlib.colors.Colormap, default: "RdBu_r"
Colormap to use for divergent data plots. If string, must be
matplotlib built-in colormap. Can also be a Colormap object
Expand Down

0 comments on commit 87b2fd0

Please sign in to comment.