It appears that certain units which are supported by get_amount (including "%" and "ppb") are not supported in the __init__ method. Ideally, __init__ should be able to interpret the full set of units that can be retrieved via get_amount.
>>> s=Solution({'Ca+2': '1000 ppb'})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ryan/mambaforge/envs/skagit2/lib/python3.12/site-packages/pyEQL/solution.py", line 250, in __init__
self.add_solute(k, v)
File "/home/ryan/mambaforge/envs/skagit2/lib/python3.12/site-packages/pyEQL/solution.py", line 1213, in add_solute
if ureg.Quantity(amount).dimensionality in (
^^^^^^^^^^^^^^^^^^^^^
File "/home/ryan/mambaforge/envs/skagit2/lib/python3.12/site-packages/pint/facets/plain/quantity.py", line 205, in __new__
inst = ureg.parse_expression(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ryan/mambaforge/envs/skagit2/lib/python3.12/site-packages/pint/facets/plain/registry.py", line 1388, in parse_expression
return build_eval_tree(gen).evaluate(_define_op)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ryan/mambaforge/envs/skagit2/lib/python3.12/site-packages/pint/pint_eval.py", line 385, in evaluate
self.right.evaluate(define_op, bin_op, un_op),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ryan/mambaforge/envs/skagit2/lib/python3.12/site-packages/pint/pint_eval.py", line 396, in evaluate
return define_op(self.left)
^^^^^^^^^^^^^^^^^^^^
File "/home/ryan/mambaforge/envs/skagit2/lib/python3.12/site-packages/pint/facets/plain/registry.py", line 1386, in _define_op
return self._eval_token(s, case_sensitive=case_sensitive, **values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ryan/mambaforge/envs/skagit2/lib/python3.12/site-packages/pint/facets/plain/registry.py", line 1295, in _eval_token
{self.get_name(token_text, case_sensitive=case_sensitive): 1}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ryan/mambaforge/envs/skagit2/lib/python3.12/site-packages/pint/facets/plain/registry.py", line 647, in get_name
raise UndefinedUnitError(name_or_alias)
pint.errors.UndefinedUnitError: 'ppb' is not defined in the unit registry
It appears that certain units which are supported by
get_amount
(including "%" and "ppb") are not supported in the__init__
method. Ideally,__init__
should be able to interpret the full set of units that can be retrieved viaget_amount
.