You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Short of a proper implementation as discussed in the linked documents, there are a few things that bug me:
this command:
pint.Quantity([1,2], "m").plus_minus(.5)
produces a very dirty Exception:
Traceback (most recent call last):
File "/Users/crusaderky/miniconda3/envs/pint/lib/python3.6/site-packages/uncertainties/core.py", line 3233, in ufloat
return Variable(nominal_value, std_dev, tag=tag)
File "/Users/crusaderky/miniconda3/envs/pint/lib/python3.6/site-packages/uncertainties/core.py", line 2719, in __init__
value = float(value)
TypeError: only size-1 arrays can be converted to Python scalars
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/crusaderky/miniconda3/envs/pint/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3326, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-20-36473b74231e>", line 1, in <module>
pint.Quantity([1,2], "m").plus_minus(.5)
File "/Users/crusaderky/PycharmProjects/pint/pint/quantity.py", line 1718, in plus_minus
return self._REGISTRY.Measurement(copy.copy(self.magnitude), error, self._units)
File "/Users/crusaderky/PycharmProjects/pint/pint/measurement.py", line 48, in __new__
mag = ufloat(value, error)
File "/Users/crusaderky/miniconda3/envs/pint/lib/python3.6/site-packages/uncertainties/core.py", line 3246, in ufloat
final_ufloat = ufloat_obsolete(nominal_value, tag_arg)
File "/Users/crusaderky/miniconda3/envs/pint/lib/python3.6/site-packages/uncertainties/core.py", line 3189, in ufloat_obsolete
return ufloat_fromstr(representation, tag)
File "/Users/crusaderky/miniconda3/envs/pint/lib/python3.6/site-packages/uncertainties/core.py", line 3173, in ufloat_fromstr
representation.strip())
AttributeError: 'numpy.ndarray' object has no attribute 'strip'
I would expect a clean TypeError "numpy and measurements are not supported together".
Same problem wiith this, but the error is different:
Traceback (most recent call last):
File "/Users/crusaderky/miniconda3/envs/pint/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3326, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-25-f57a4fd9ba92>", line 1, in <module>
pint.Quantity("1 kg").plus_minus(pint.Quantity([1, 2], "kg"))
File "/Users/crusaderky/PycharmProjects/pint/pint/quantity.py", line 1718, in plus_minus
return self._REGISTRY.Measurement(copy.copy(self.magnitude), error, self._units)
File "/Users/crusaderky/PycharmProjects/pint/pint/measurement.py", line 45, in __new__
elif error < 0:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
https://pint.readthedocs.io/en/latest/measurement.html starts with import numpy as np, which is then not used in the document. On the opposite, the document should clearly state that measurements and numpy don't work together.
The text was updated successfully, but these errors were encountered:
As of most recent release, using numpy and uncertainties together still is impossible. Is there any development plan to make this possible? This would be a very convenient feature.
As of git tip, pint doesn't support measurements and numpy at the same time.
XREF: #128, #350
Also related: #734
Short of a proper implementation as discussed in the linked documents, there are a few things that bug me:
produces a very dirty Exception:
I would expect a clean TypeError "numpy and measurements are not supported together".
import numpy as np
, which is then not used in the document. On the opposite, the document should clearly state that measurements and numpy don't work together.The text was updated successfully, but these errors were encountered: