Skip to content

Commit

Permalink
DOC: mention attribute peculiarities in docs/docstrings (#9700)
Browse files Browse the repository at this point in the history
* mention attribute peculiarities in docs/docstrings
* add whats-new.rst
  • Loading branch information
kmuehlbauer authored Nov 4, 2024
1 parent 3723099 commit 29654fc
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/getting-started-guide/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ for conflicts between ``attrs`` when combining arrays and datasets, unless
explicitly requested with the option ``compat='identical'``. The guiding
principle is that metadata should not be allowed to get in the way.

In general xarray uses the capabilities of the backends for reading and writing
attributes. That has some implications on roundtripping. One example for such inconsistency is that size-1 lists will roundtrip as single element (for netcdf4 backends).

What other netCDF related Python libraries should I know about?
---------------------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion doc/user-guide/data-structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ alignment, building on the functionality of the ``index`` found on a pandas
DataArray objects also can have a ``name`` and can hold arbitrary metadata in
the form of their ``attrs`` property. Names and attributes are strictly for
users and user-written code: xarray makes no attempt to interpret them, and
propagates them only in unambiguous cases
propagates them only in unambiguous cases. For reading and writing attributes
xarray relies on the capabilities of the supported backends.
(see FAQ, :ref:`approach to metadata`).

.. _creating a dataarray:
Expand Down
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Bug fixes
Documentation
~~~~~~~~~~~~~

- Mention attribute peculiarities in docs/docstrings (:issue:`4798`, :pull:`9700`).
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.


Internal Changes
~~~~~~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ class DataArray(
attrs : dict_like or None, optional
Attributes to assign to the new instance. By default, an empty
attribute dictionary is initialized.
(see FAQ, :ref:`approach to metadata`)
indexes : py:class:`~xarray.Indexes` or dict-like, optional
For internal use only. For passing indexes objects to the
new DataArray, use the ``coords`` argument instead with a
Expand Down
1 change: 1 addition & 0 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ class Dataset(
attrs : dict-like, optional
Global attributes to save on this dataset.
(see FAQ, :ref:`approach to metadata`)
Examples
--------
Expand Down
1 change: 1 addition & 0 deletions xarray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def __init__(
attrs : dict_like or None, optional
Attributes to assign to the new variable. If None (default), an
empty attribute dictionary is initialized.
(see FAQ, :ref:`approach to metadata`)
encoding : dict_like or None, optional
Dictionary specifying how to encode this array's data into a
serialized format like netCDF4. Currently used keys (for netCDF)
Expand Down

0 comments on commit 29654fc

Please sign in to comment.