"Tracking" units through calculations #31
-
When I do a calculation like this: v = Quantity("1 A") * Quantity("10 kOhm")
print(v)
print(type(v)) I get:
I would really like to end up with another |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The whole unit propagation issue is a deep hole with many gotchas. It is outside the scope of QuantiPhy to address it. There are other packages, such as pint, that specialize in units. However it is possible to add unit propagation to QuantiPhy that works in typical cases when the problem is constrained. Take a look at my unit_propagation repository. You can start with that and add rules (simplifications) to fit your situation. The package is largely an experiment for me, so it is not in pypi. It includes a simple RPN calculator demonstrator program that you can used to quickly get a feel for the capabilities and limitations of the package. |
Beta Was this translation helpful? Give feedback.
The whole unit propagation issue is a deep hole with many gotchas. It is outside the scope of QuantiPhy to address it. There are other packages, such as pint, that specialize in units. However it is possible to add unit propagation to QuantiPhy that works in typical cases when the problem is constrained.
Take a look at my unit_propagation repository. You can start with that and add rules (simplifications) to fit your situation. The package is largely an experiment for me, so it is not in pypi. It includes a simple RPN calculator demonstrator program that you can used to quickly get a feel for the capabilities and limitations of the package.