Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/pyEQL/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ def _translate_pint_quantity(amount: str):
return amount.magnitude, str(amount.units)

match = re.match(r"^\s*([+-]?\d*\.?\d+(?:[eE][+-]?\d+)?)\s*(.*)$", amount)

if match is None:
return amount

_value, _unit = match.groups()
# handle python ** expression in Pint quantity
_value = eval(_value) if "**" in _value else float(_value)
unit = translate_units(_unit)
return (float(_value), unit)

Expand Down
Loading