Skip to content

Commit 29654fc

Browse files
authored
DOC: mention attribute peculiarities in docs/docstrings (#9700)
* mention attribute peculiarities in docs/docstrings * add whats-new.rst
1 parent 3723099 commit 29654fc

File tree

6 files changed

+11
-1
lines changed

6 files changed

+11
-1
lines changed

doc/getting-started-guide/faq.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ for conflicts between ``attrs`` when combining arrays and datasets, unless
146146
explicitly requested with the option ``compat='identical'``. The guiding
147147
principle is that metadata should not be allowed to get in the way.
148148

149+
In general xarray uses the capabilities of the backends for reading and writing
150+
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).
151+
149152
What other netCDF related Python libraries should I know about?
150153
---------------------------------------------------------------
151154

doc/user-guide/data-structures.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ alignment, building on the functionality of the ``index`` found on a pandas
4040
DataArray objects also can have a ``name`` and can hold arbitrary metadata in
4141
the form of their ``attrs`` property. Names and attributes are strictly for
4242
users and user-written code: xarray makes no attempt to interpret them, and
43-
propagates them only in unambiguous cases
43+
propagates them only in unambiguous cases. For reading and writing attributes
44+
xarray relies on the capabilities of the supported backends.
4445
(see FAQ, :ref:`approach to metadata`).
4546

4647
.. _creating a dataarray:

doc/whats-new.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ Bug fixes
4343
Documentation
4444
~~~~~~~~~~~~~
4545

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

4750
Internal Changes
4851
~~~~~~~~~~~~~~~~

xarray/core/dataarray.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ class DataArray(
347347
attrs : dict_like or None, optional
348348
Attributes to assign to the new instance. By default, an empty
349349
attribute dictionary is initialized.
350+
(see FAQ, :ref:`approach to metadata`)
350351
indexes : py:class:`~xarray.Indexes` or dict-like, optional
351352
For internal use only. For passing indexes objects to the
352353
new DataArray, use the ``coords`` argument instead with a

xarray/core/dataset.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ class Dataset(
596596
597597
attrs : dict-like, optional
598598
Global attributes to save on this dataset.
599+
(see FAQ, :ref:`approach to metadata`)
599600
600601
Examples
601602
--------

xarray/core/variable.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ def __init__(
401401
attrs : dict_like or None, optional
402402
Attributes to assign to the new variable. If None (default), an
403403
empty attribute dictionary is initialized.
404+
(see FAQ, :ref:`approach to metadata`)
404405
encoding : dict_like or None, optional
405406
Dictionary specifying how to encode this array's data into a
406407
serialized format like netCDF4. Currently used keys (for netCDF)

0 commit comments

Comments
 (0)