Closed mikofski closed 10 years ago
The issue here is in measurements.py on line 94 where __repr__
is defined, I think the formatter should be {!r}
instead of {:!r}
See Python string docs. IE: without the colon. EG: here is a patch.
--- /c/Python27/lib/site-packages/pint/measurement.py.orig Mon Dec 9 13:17:41 2013
+++ /c/Python27/lib/site-packages/pint/measurement.py Mon Dec 9 13:18:42 2013
@@ -91,7 +91,7 @@
return '{}'.format(self)
def __repr__(self):
- return "<Measurement({:!r}, {:!r})>".format(self._value, self._error)
+ return "<Measurement({!r}, {!r})>".format(self._value, self._error)
def __format__(self, spec):
if '!' in spec:
Now this yields:
>>> from pint import UnitRegistry
>>> ureg = UnitRegistry()
>>> acc = (5.0 * ureg['m/s/s']).plus_minus(0.25)
>>> tim = (37.0 * ureg['s']).plus_minus(0.16)
>>> dis = acc * tim * tim / 2.0
>>> dis
<Measurement(<Quantity(3422.0, 'meter')>, <Quantity(172.0, 'meter')>)>
Is this the output you intended?
FYI: see issue #77 for why I have to use tim * tim
instead of pow()
Thanks for your interest in this. The plan is to provide a better Measurement class via the uncertainties package. Checkout the _uncertainties branch. The bug in #77 and #76 is due to the fact that this was lagging behind. Would you like to submit a pull request?
Thanks for your response. I would love to contribute if I find time. Looking forward to the Uncertainties & Pint integration. Hoping for full NumPy/SciPy support for scientists and engineers. Thanks for your work!
See Using Measurments