Skip to content

Operations with units that have offsets result in unwrapped error

Operations with quantities that have units with offsets are documented in the documentation of the pint package. However TextS has problems with such operations. Consider the following texts session example:

Input > a = 10 [kelvin]
Input > b = 100 [celsius]
Input > c = a+b

The following error message is printed as output:

Traceback (most recent call last):
  File "/hkfs/home/project/hk-project-consulting/an9294/python_VirtEnvs/vre-lang/lib/python3.9/site-packages/fireworks/core/rocket.py", line 261, in run
    m_action = t.run_task(my_spec)
  File "/hkfs/home/project/hk-project-consulting/an9294/vre-language/src/virtmat/language/utilities/firetasks.py", line 33, in run_task
    raise err
  File "/hkfs/home/project/hk-project-consulting/an9294/vre-language/src/virtmat/language/utilities/firetasks.py", line 25, in run_task
    f_output = func(*params)
  File "/hkfs/home/project/hk-project-consulting/an9294/vre-language/src/virtmat/language/interpreter/deferred_executor.py", line 560, in <lambda>
    lambda *args: operator(left_func(*args[0:left_pars_length]),
  File "/hkfs/home/project/hk-project-consulting/an9294/python_VirtEnvs/vre-lang/lib/python3.9/site-packages/pint/facets/plain/quantity.py", line 841, in __add__
    return self._add_sub(other, operator.add)
  File "/hkfs/home/project/hk-project-consulting/an9294/python_VirtEnvs/vre-lang/lib/python3.9/site-packages/pint/facets/plain/quantity.py", line 103, in wrapped
    return f(self, *args, **kwargs)
  File "/hkfs/home/project/hk-project-consulting/an9294/python_VirtEnvs/vre-lang/lib/python3.9/site-packages/pint/facets/plain/quantity.py", line 817, in _add_sub
    raise OffsetUnitCalculusError(self._units, other._units)
pint.errors.OffsetUnitCalculusError: Ambiguous operation with offset unit (kelvin, degree_Celsius). See https://pint.readthedocs.io/en/stable/user/nonmult.html for guidance