Conflict in unit alias
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Reproduce the example using Pint's application_registry, NumPy, and the cf_xarray.units import shown in the report, then inspect how the CF units are registered and how the electron-volt alias changes. Done means the documented conversion from electron temperature to thermal velocity still converts to km/s after importing cf_xarray.units, with a regression check for the reported conflict.
Written by the indexing model from the issue text.
Description
Take a conversion from electron temperature to thermal velocity as an example:
from pint import application_registry as u
import numpy as np
np.sqrt(100 * u.eV / u.m_e).to("km/s")
# <Quantity(4193.82881, 'kilometer / second')>
If we then import cf_xarray.units to enable CF units, per this page, we get the following error:
import cf_xarray.units
np.sqrt(100 * u.eV / u.m_e).to("km/s")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tvo/.local/share/mamba/envs/test_xarray_units/lib/python3.12/site-packages/pint/facets/plain/quantity.py", line 536, in to
magnitude = self._convert_magnitude_not_inplace(other, *contexts, **ctx_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tvo/.local/share/mamba/envs/test_xarray_units/lib/python3.12/site-packages/pint/facets/plain/quantity.py", line 480, in _convert_magnitude_not_inplace
return self._REGISTRY.convert(self._magnitude, self._units, other)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tvo/.local/share/mamba/envs/test_xarray_units/lib/python3.12/site-packages/pint/facets/plain/registry.py", line 1041, in convert
return self._convert(value, src, dst, inplace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tvo/.local/share/mamba/envs/test_xarray_units/lib/python3.12/site-packages/pint/facets/context/registry.py", line 405, in _convert
return super()._convert(value, src, dst, inplace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tvo/.local/share/mamba/envs/test_xarray_units/lib/python3.12/site-packages/pint/facets/nonmultiplicative/registry.py", line 259, in _convert
return super()._convert(value, src, dst, inplace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tvo/.local/share/mamba/envs/test_xarray_units/lib/python3.12/site-packages/pint/facets/plain/registry.py", line 1076, in _convert
raise factor
pint.errors.DimensionalityError: Cannot convert from 'electron_volt ** 0.5 / electron_mass ** 0.5' ([temperature] ** 0.5 * [length] / [time] ** 1.5 / [current] ** 0.5) to 'kilometer / second' ([length] / [time])
- Dominant language
- Python
- Stars
- 181
- Forks
- 49
- Avg merge
- 43m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from xarray-contrib/cf-xarray
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
xarray-contrib/cf-xarray#623 ·
-
Consider adding opt-in support for circular axes when calling `bounds_to_vertices` (related to #594) Open
Difficulty 5/5 Over a week Newbie friendliness 38/100
xarray-contrib/cf-xarray#596 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
xarray-contrib/cf-xarray#570 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 15/100
xarray-contrib/cf-xarray#568 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
xarray-contrib/cf-xarray#566 · 2 comments ·
All issues in xarray-contrib/cf-xarray
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
use-agent-os/agent-os#3314 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AiursoftWeb/AnduinOS-2#19 ·