From c68ce57284606eacad05efa7a761e7fac5cb1f47 Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 2 Sep 2020 22:43:02 +0200 Subject: [PATCH 01/20] use the application registry instead of creating a new one --- pint_xarray/accessors.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/pint_xarray/accessors.py b/pint_xarray/accessors.py index 303aae14..4df7a101 100644 --- a/pint_xarray/accessors.py +++ b/pint_xarray/accessors.py @@ -82,13 +82,15 @@ def either_dict_or_kwargs(positional, keywords, method_name): return keywords -def _get_registry(unit_registry, registry_kwargs): +def get_registry(unit_registry): if unit_registry is None: - if registry_kwargs is None: - registry_kwargs = {} - registry_kwargs.update(force_ndarray=True) - # TODO should this registry object then be stored somewhere global? - unit_registry = pint.UnitRegistry(**registry_kwargs) + unit_registry = pint.get_application_registry() + + if not unit_registry.force_ndarray_like and not unit_registry.force_ndarray: + raise ValueError( + "invalid registry. Please enable 'force_ndarray_like' or 'force_ndarray'." + ) + return unit_registry @@ -120,9 +122,7 @@ class PintDataArrayAccessor: def __init__(self, da): self.da = da - def quantify( - self, units=None, unit_registry=None, registry_kwargs=None, **unit_kwargs - ): + def quantify(self, units=None, unit_registry=None, **unit_kwargs): """ Attaches units to the DataArray. @@ -155,8 +155,6 @@ def quantify( unit_registry : pint.UnitRegistry, optional Unit registry to be used for the units attached to this DataArray. If not given then a default registry will be created. - registry_kwargs : dict, optional - Keyword arguments to be passed to the unit registry. **unit_kwargs Keyword argument form of units. @@ -197,7 +195,7 @@ def quantify( units = either_dict_or_kwargs(units, unit_kwargs, ".quantify") - registry = _get_registry(unit_registry, registry_kwargs) + registry = get_registry(unit_registry) unit_attrs = conversion.extract_unit_attributes(self.da) new_obj = conversion.strip_unit_attributes(self.da) @@ -391,9 +389,7 @@ class PintDatasetAccessor: def __init__(self, ds): self.ds = ds - def quantify( - self, units=None, unit_registry=None, registry_kwargs=None, **unit_kwargs - ): + def quantify(self, units=None, unit_registry=None, **unit_kwargs): """ Attaches units to each variable in the Dataset. @@ -426,8 +422,6 @@ def quantify( Unit registry to be used for the units attached to each DataArray in this Dataset. If not given then a default registry will be created. - registry_kwargs : dict, optional - Keyword arguments to be passed to `pint.UnitRegistry`. **unit_kwargs Keyword argument form of ``units``. @@ -464,7 +458,7 @@ def quantify( b (x) int64 """ units = either_dict_or_kwargs(units, unit_kwargs, ".quantify") - registry = _get_registry(unit_registry, registry_kwargs) + registry = get_registry(unit_registry) unit_attrs = conversion.extract_unit_attributes(self.ds) new_obj = conversion.strip_unit_attributes(self.ds) From 322400acdd3b4ac6ccf69b27751e43663be2a97d Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 2 Sep 2020 23:08:30 +0200 Subject: [PATCH 02/20] try to get the unit registry from units or existing quantities --- pint_xarray/accessors.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/pint_xarray/accessors.py b/pint_xarray/accessors.py index 4df7a101..c9728128 100644 --- a/pint_xarray/accessors.py +++ b/pint_xarray/accessors.py @@ -57,6 +57,14 @@ def zip_mappings(*mappings, fill_value=None): return zipped +def merge_mappings(first, *mappings): + result = first.copy() + for mapping in mappings: + result.update(mapping) + + return result + + def units_to_str_or_none(mapping): return { key: str(value) if isinstance(value, Unit) else value @@ -82,9 +90,20 @@ def either_dict_or_kwargs(positional, keywords, method_name): return keywords -def get_registry(unit_registry): +def get_registry(unit_registry, units): + registries = {unit._REGISTRY for unit in units.values() if isinstance(unit, Unit)} + if unit_registry is None: - unit_registry = pint.get_application_registry() + if not registries: + unit_registry = pint.get_application_registry() + registries.add(unit_registry) + elif len(registries) == 1: + (unit_registry,) = registries + + if len(registries) > 1 or unit_registry not in registries: + raise ValueError( + "using multiple unit registries in the same object is not supported" + ) if not unit_registry.force_ndarray_like and not unit_registry.force_ndarray: raise ValueError( @@ -195,7 +214,10 @@ def quantify(self, units=None, unit_registry=None, **unit_kwargs): units = either_dict_or_kwargs(units, unit_kwargs, ".quantify") - registry = get_registry(unit_registry) + registry = get_registry( + unit_registry, + merge_mappings(units, conversion.extract_units(self.da)), + ) unit_attrs = conversion.extract_unit_attributes(self.da) new_obj = conversion.strip_unit_attributes(self.da) @@ -458,7 +480,10 @@ def quantify(self, units=None, unit_registry=None, **unit_kwargs): b (x) int64 """ units = either_dict_or_kwargs(units, unit_kwargs, ".quantify") - registry = get_registry(unit_registry) + registry = get_registry( + unit_registry, + merge_mappings(units, conversion.extract_units(self.ds)), + ) unit_attrs = conversion.extract_unit_attributes(self.ds) new_obj = conversion.strip_unit_attributes(self.ds) From b21728f6320b9b6fbfdf400be52efb626be9c6c5 Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 2 Sep 2020 23:12:33 +0200 Subject: [PATCH 03/20] use a module-local registry instead of the application registry --- pint_xarray/__init__.py | 1 + pint_xarray/accessors.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pint_xarray/__init__.py b/pint_xarray/__init__.py index ef933c46..768b84b4 100644 --- a/pint_xarray/__init__.py +++ b/pint_xarray/__init__.py @@ -8,6 +8,7 @@ from . import testing # noqa: F401 from . import formatting from .accessors import PintDataArrayAccessor, PintDatasetAccessor # noqa: F401 +from .accessors import _registry as unit_registry # noqa: F401 try: __version__ = version("pint-xarray") diff --git a/pint_xarray/accessors.py b/pint_xarray/accessors.py index c9728128..a864adb6 100644 --- a/pint_xarray/accessors.py +++ b/pint_xarray/accessors.py @@ -18,6 +18,9 @@ raise ImportError("NUMPY_EXPERIMENTAL_ARRAY_FUNCTION is not enabled") +_registry = pint.UnitRegistry(force_ndarray_like=True) + + # TODO could/should we overwrite xr.open_dataset and xr.open_mfdataset to make # them apply units upon loading??? # TODO could even override the decode_cf kwarg? @@ -95,7 +98,7 @@ def get_registry(unit_registry, units): if unit_registry is None: if not registries: - unit_registry = pint.get_application_registry() + unit_registry = _registry registries.add(unit_registry) elif len(registries) == 1: (unit_registry,) = registries From 4af2849b51bf027117c46ce5ff02bcc998755bef Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 2 Sep 2020 23:37:21 +0200 Subject: [PATCH 04/20] fix get_registry --- pint_xarray/accessors.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pint_xarray/accessors.py b/pint_xarray/accessors.py index a864adb6..adb0cec7 100644 --- a/pint_xarray/accessors.py +++ b/pint_xarray/accessors.py @@ -63,7 +63,9 @@ def zip_mappings(*mappings, fill_value=None): def merge_mappings(first, *mappings): result = first.copy() for mapping in mappings: - result.update(mapping) + result.update( + {key: value for key, value in mapping.items() if value is not None} + ) return result @@ -99,9 +101,9 @@ def get_registry(unit_registry, units): if unit_registry is None: if not registries: unit_registry = _registry - registries.add(unit_registry) elif len(registries) == 1: (unit_registry,) = registries + registries.add(unit_registry) if len(registries) > 1 or unit_registry not in registries: raise ValueError( From 976837449e698d18ee144d2b2a4b3da69a7aac09 Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 2 Sep 2020 23:37:35 +0200 Subject: [PATCH 05/20] fix the registry property of DataArray --- pint_xarray/accessors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pint_xarray/accessors.py b/pint_xarray/accessors.py index adb0cec7..5c2392e8 100644 --- a/pint_xarray/accessors.py +++ b/pint_xarray/accessors.py @@ -285,7 +285,7 @@ def dimensionality(self): @property def registry(self): # TODO is this a bad idea? (see GH issue #1071 in pint) - return self.data._REGISTRY + return getattr(self.da.data, "_REGISTRY", None) @registry.setter def registry(self, _): From aa26ce2693798b405827a3e660cb4b4e78418143 Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 3 Sep 2020 02:08:53 +0200 Subject: [PATCH 06/20] remove the registry_kwargs test --- pint_xarray/tests/test_accessors.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pint_xarray/tests/test_accessors.py b/pint_xarray/tests/test_accessors.py index 8867af8a..2dcd5df7 100644 --- a/pint_xarray/tests/test_accessors.py +++ b/pint_xarray/tests/test_accessors.py @@ -94,11 +94,6 @@ def test_error_on_nonsense_units(self, example_unitless_da): with pytest.raises(UndefinedUnitError): da.pint.quantify(units="aecjhbav") - def test_registry_kwargs(self, example_unitless_da): - orig = example_unitless_da - result = orig.pint.quantify(registry_kwargs={"auto_reduce_dimensions": True}) - assert result.data._REGISTRY.auto_reduce_dimensions is True - class TestDequantifyDataArray: def test_strip_units(self, example_quantity_da): From e48b95d1e18ec9740e261349be923afdbe64431b Mon Sep 17 00:00:00 2001 From: Keewis Date: Fri, 4 Sep 2020 17:39:25 +0200 Subject: [PATCH 07/20] merge the units in get_registry --- pint_xarray/accessors.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pint_xarray/accessors.py b/pint_xarray/accessors.py index 5c2392e8..4c8f4e61 100644 --- a/pint_xarray/accessors.py +++ b/pint_xarray/accessors.py @@ -95,7 +95,8 @@ def either_dict_or_kwargs(positional, keywords, method_name): return keywords -def get_registry(unit_registry, units): +def get_registry(unit_registry, new_units, existing_units): + units = merge_mappings(existing_units, new_units) registries = {unit._REGISTRY for unit in units.values() if isinstance(unit, Unit)} if unit_registry is None: @@ -221,7 +222,8 @@ def quantify(self, units=None, unit_registry=None, **unit_kwargs): registry = get_registry( unit_registry, - merge_mappings(units, conversion.extract_units(self.da)), + units, + conversion.extract_units(self.da), ) unit_attrs = conversion.extract_unit_attributes(self.da) @@ -487,7 +489,8 @@ def quantify(self, units=None, unit_registry=None, **unit_kwargs): units = either_dict_or_kwargs(units, unit_kwargs, ".quantify") registry = get_registry( unit_registry, - merge_mappings(units, conversion.extract_units(self.ds)), + units, + conversion.extract_units(self.ds), ) unit_attrs = conversion.extract_unit_attributes(self.ds) From 6efdece698e429c079eb42c375dd1dcb9abc902d Mon Sep 17 00:00:00 2001 From: Keewis Date: Fri, 4 Sep 2020 17:47:16 +0200 Subject: [PATCH 08/20] don't use the name of the DataArray to set the units --- docs/creation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/creation.rst b/docs/creation.rst index ecf6c29e..9af20b25 100644 --- a/docs/creation.rst +++ b/docs/creation.rst @@ -40,7 +40,7 @@ We can also override the units of a variable: In [4]: ds.pint.quantify(b="km") - In [5]: da.pint.quantify({"b": "degree"}) + In [5]: da.pint.quantify("degree") Overriding works, even if there is no ``units`` attribute, so we could use this to attach units to a normal :py:class:`Dataset`: From f890a36076f9f045c4e2973ca239018891fa8208 Mon Sep 17 00:00:00 2001 From: Keewis Date: Fri, 4 Sep 2020 17:47:41 +0200 Subject: [PATCH 09/20] remove a comma --- docs/creation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/creation.rst b/docs/creation.rst index 9af20b25..1eb49df1 100644 --- a/docs/creation.rst +++ b/docs/creation.rst @@ -42,7 +42,7 @@ We can also override the units of a variable: In [5]: da.pint.quantify("degree") -Overriding works, even if there is no ``units`` attribute, so we could use this +Overriding works even if there is no ``units`` attribute, so we could use this to attach units to a normal :py:class:`Dataset`: .. ipython:: From 02b8cc1a6e55a810f617c2ef7db2cfbb6fcd35ca Mon Sep 17 00:00:00 2001 From: Keewis Date: Fri, 4 Sep 2020 17:48:31 +0200 Subject: [PATCH 10/20] mention that quantify will reject units from multiple registries --- docs/creation.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/creation.rst b/docs/creation.rst index 1eb49df1..f00c2e4f 100644 --- a/docs/creation.rst +++ b/docs/creation.rst @@ -53,6 +53,13 @@ to attach units to a normal :py:class:`Dataset`: Of course, we could use :py:class:`pint.Unit` instances instead of strings to specify units, too. +.. note:: + + Unit objects tied to different registries cannot interact with each + other. In order to avoid this, :py:meth:`DataArray.pint.quantify` and + :py:meth:`Dataset.pint.quantify` will make sure only a single registry is + used per ``xarray`` object. + If we wanted to change the units of the data of a :py:class:`DataArray`, we could do so using the :py:attr:`DataArray.name` attribute: From b85d5c151e339b925d5c71a624f477e77387a23e Mon Sep 17 00:00:00 2001 From: Keewis Date: Fri, 4 Sep 2020 17:48:50 +0200 Subject: [PATCH 11/20] document overriding the default registry --- docs/creation.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/creation.rst b/docs/creation.rst index f00c2e4f..1040b1a3 100644 --- a/docs/creation.rst +++ b/docs/creation.rst @@ -83,6 +83,31 @@ have to first swap the dimensions: ...: ) ...: da_with_units +By default, :py:meth:`Dataset.pint.quantify` and +:py:meth:`DataArray.pint.quantify` will use the unit registry at +:py:obj:`pint_xarray.unit_registry`. If we want a different registry, we can +either pass it as the ``unit_registry`` parameter: + +.. ipython:: + + In [10]: ureg = pint.UnitRegistry(force_ndarray_like=True) + ...: # set up the registry + + In [11]: da.pint.quantify("degree", unit_registry=ureg) + +or overwrite the default registry: + +.. ipython:: + + In [12]: pint_xarray.unit_registry = ureg + + In [13]: da.pint.quantify("degree") + +.. note:: + + To properly work with ``xarray``, the ``force_ndarray_like`` or + ``force_ndarray`` options have to be enabled on the custom registry. + Saving with units ----------------- In order to not lose the units when saving to disk, we first have to call the From 1287eda82077800cb99979db7cbcfde7ed3b6de1 Mon Sep 17 00:00:00 2001 From: Keewis Date: Fri, 4 Sep 2020 17:51:07 +0200 Subject: [PATCH 12/20] rename the default registry to default_registry --- pint_xarray/__init__.py | 2 +- pint_xarray/accessors.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pint_xarray/__init__.py b/pint_xarray/__init__.py index 768b84b4..f96f6ab6 100644 --- a/pint_xarray/__init__.py +++ b/pint_xarray/__init__.py @@ -8,7 +8,7 @@ from . import testing # noqa: F401 from . import formatting from .accessors import PintDataArrayAccessor, PintDatasetAccessor # noqa: F401 -from .accessors import _registry as unit_registry # noqa: F401 +from .accessors import default_registry as unit_registry # noqa: F401 try: __version__ = version("pint-xarray") diff --git a/pint_xarray/accessors.py b/pint_xarray/accessors.py index e3396d3c..6013ec7c 100644 --- a/pint_xarray/accessors.py +++ b/pint_xarray/accessors.py @@ -8,7 +8,7 @@ from . import conversion -_registry = pint.UnitRegistry(force_ndarray_like=True) +default_registry = pint.UnitRegistry(force_ndarray_like=True) # TODO could/should we overwrite xr.open_dataset and xr.open_mfdataset to make # them apply units upon loading??? @@ -90,7 +90,7 @@ def get_registry(unit_registry, new_units, existing_units): if unit_registry is None: if not registries: - unit_registry = _registry + unit_registry = default_registry elif len(registries) == 1: (unit_registry,) = registries registries.add(unit_registry) From 5c4152bc29a28105faa00f87d14215a48150833a Mon Sep 17 00:00:00 2001 From: Keewis Date: Fri, 4 Sep 2020 17:51:52 +0200 Subject: [PATCH 13/20] load pint into the docs namespace --- docs/creation.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/creation.rst b/docs/creation.rst index 1040b1a3..e8cd641a 100644 --- a/docs/creation.rst +++ b/docs/creation.rst @@ -9,6 +9,7 @@ Attaching units :suppress: import xarray as xr + import pint Usually, when loading data from disk we get a :py:class:`Dataset` or :py:class:`DataArray` with units in attributes: From 8824f35077b231241d4f71bce8035b361fbb31ac Mon Sep 17 00:00:00 2001 From: Keewis Date: Fri, 4 Sep 2020 17:54:00 +0200 Subject: [PATCH 14/20] also load pint_xarray --- docs/creation.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/creation.rst b/docs/creation.rst index e8cd641a..fb1b1e00 100644 --- a/docs/creation.rst +++ b/docs/creation.rst @@ -8,8 +8,9 @@ Attaching units .. ipython:: python :suppress: - import xarray as xr import pint + import pint_xarray + import xarray as xr Usually, when loading data from disk we get a :py:class:`Dataset` or :py:class:`DataArray` with units in attributes: From f9700a97ae0790cb07c92070d0febf0a7064b234 Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 22 Oct 2020 16:13:50 +0200 Subject: [PATCH 15/20] add a function set up a registry for use with pint_xarray --- pint_xarray/accessors.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pint_xarray/accessors.py b/pint_xarray/accessors.py index 1c23b9df..0e870aa2 100644 --- a/pint_xarray/accessors.py +++ b/pint_xarray/accessors.py @@ -10,6 +10,32 @@ default_registry = pint.UnitRegistry(force_ndarray_like=True) + +def setup_registry(registry=None): + """set up the given registry for use with pint_xarray + + Namely, it enables ``force_ndarray_like`` to make sure results are always + duck arrays. + + Parameters + ---------- + registry : pint.UnitRegistry, optional + The registry to use. If not given, the application registry is used. + + See also + -------- + pint.get_application_registry + pint.set_application_registry + """ + if registry is None: + registry = default_registry + + if not registry.force_ndarray and not registry.force_ndarray_like: + registry.force_ndarray_like = True + + return registry + + # TODO could/should we overwrite xr.open_dataset and xr.open_mfdataset to make # them apply units upon loading??? # TODO could even override the decode_cf kwarg? From b675ee38b6cadf889c10aa0e7c1dd2e302d6773f Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 22 Oct 2020 16:16:41 +0200 Subject: [PATCH 16/20] replace the default registry with the application registry --- pint_xarray/accessors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pint_xarray/accessors.py b/pint_xarray/accessors.py index 0e870aa2..ecb36168 100644 --- a/pint_xarray/accessors.py +++ b/pint_xarray/accessors.py @@ -8,7 +8,7 @@ from . import conversion -default_registry = pint.UnitRegistry(force_ndarray_like=True) +default_registry = pint.get_application_registry() def setup_registry(registry=None): From fffa6c72dc16b6f9477804fcf6d7fafd8806ef3a Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 22 Oct 2020 16:18:27 +0200 Subject: [PATCH 17/20] simplify the setup function --- pint_xarray/accessors.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pint_xarray/accessors.py b/pint_xarray/accessors.py index ecb36168..085ce819 100644 --- a/pint_xarray/accessors.py +++ b/pint_xarray/accessors.py @@ -8,10 +8,8 @@ from . import conversion -default_registry = pint.get_application_registry() - -def setup_registry(registry=None): +def setup_registry(registry): """set up the given registry for use with pint_xarray Namely, it enables ``force_ndarray_like`` to make sure results are always @@ -27,15 +25,14 @@ def setup_registry(registry=None): pint.get_application_registry pint.set_application_registry """ - if registry is None: - registry = default_registry - if not registry.force_ndarray and not registry.force_ndarray_like: registry.force_ndarray_like = True return registry +default_registry = setup_registry(pint.get_application_registry()) + # TODO could/should we overwrite xr.open_dataset and xr.open_mfdataset to make # them apply units upon loading??? # TODO could even override the decode_cf kwarg? From ed8de4efae3023687838ff9119fec16d47c36c4f Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 22 Oct 2020 16:26:48 +0200 Subject: [PATCH 18/20] update the docstring --- pint_xarray/accessors.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pint_xarray/accessors.py b/pint_xarray/accessors.py index 085ce819..dbc1d27a 100644 --- a/pint_xarray/accessors.py +++ b/pint_xarray/accessors.py @@ -17,13 +17,8 @@ def setup_registry(registry): Parameters ---------- - registry : pint.UnitRegistry, optional - The registry to use. If not given, the application registry is used. - - See also - -------- - pint.get_application_registry - pint.set_application_registry + registry : pint.UnitRegistry + The registry to modify """ if not registry.force_ndarray and not registry.force_ndarray_like: registry.force_ndarray_like = True From 20a3e3eb590a073ee4480836f4e22a183bea11c7 Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 22 Oct 2020 17:13:35 +0200 Subject: [PATCH 19/20] update whats-new.rst --- docs/whats-new.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/whats-new.rst b/docs/whats-new.rst index 8c219a08..38961d66 100644 --- a/docs/whats-new.rst +++ b/docs/whats-new.rst @@ -13,3 +13,4 @@ What's new - fix the :py:attr:`DataArray.pint.units`, :py:attr:`DataArray.pint.magnitude` and :py:attr:`DataArray.pint.dimensionality` properties and add docstrings for all three. (:pull:`31`) +- use ``pint``'s application registry as a module-global registry (:pull:`32`) From dffd9d201e50b2bcb8c4da83363e6f19062254b3 Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 22 Oct 2020 17:18:46 +0200 Subject: [PATCH 20/20] mention that the default registry is the application registry --- docs/creation.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/creation.rst b/docs/creation.rst index fb1b1e00..37e9f9fb 100644 --- a/docs/creation.rst +++ b/docs/creation.rst @@ -87,8 +87,9 @@ have to first swap the dimensions: By default, :py:meth:`Dataset.pint.quantify` and :py:meth:`DataArray.pint.quantify` will use the unit registry at -:py:obj:`pint_xarray.unit_registry`. If we want a different registry, we can -either pass it as the ``unit_registry`` parameter: +:py:obj:`pint_xarray.unit_registry` (the +:py:func:`application registry `). If we want a +different registry, we can either pass it as the ``unit_registry`` parameter: .. ipython::