Skip to content

Instantly share code, notes, and snippets.

View BenPortner's full-sized avatar

Benjamin W. Portner BenPortner

View GitHub Profile
@BenPortner
BenPortner / pint-sympy-example.py
Last active January 20, 2023 12:25
Solve equation systems including units with pint and sympy
"""
Note: the most recent version of pint contains [a bug](https://github.com/hgrecco/pint/pull/1701).
Install [this version of pint](https://github.com/BenPortner/pint/tree/fix-subtraction-error) to
run below code.
"""
from pint.facets.plain.registry import build_eval_tree, tokenizer
from pint.util import string_preprocessor
from pint import UnitRegistry
from sympy.parsing.sympy_parser import parse_expr