varchasgopalaswamy / AutoUncertainties

Drop-in Uncertainty Propagation with Automatic Differentiation
https://autouncertainties.readthedocs.io/en/latest/
Other
4 stars 1 forks source link

Cannot reproduce demonstrations from README #3

Open MichaelTiemannOSC opened 1 year ago

MichaelTiemannOSC commented 1 year ago

I have attempted to duplicate the first example in the README:

>>> import auto_uncertainties
>>> from auto_uncertainties import *
>>> value = 1.0
>>> error = 0.1
>>> u = Uncertainty(value,error)
>>> u
[1.0 +/- 0.1]
>>> type(u)
<class 'auto_uncertainties.uncertainty.Uncertainty'>
>>> u.value
array(1.)
>>> u.error
array(0.1)
>>> 

The zero-dimensional arrays are causing problems. They can be explicitly casted to floats, but that's not convenient.

MichaelTiemannOSC commented 1 year ago

As an additional example, when I create an array of uncertainties, an element of that array similarly looks like a zero-dimensional array, not a simple Uncertainty:

>>> yy = Uncertainty([1., 2., 3.,], [4., 5., 6.,])
>>> yy
[1.0 +/- 4.0, 2.0 +/- 5.0, 3.0 +/- 6.0]
>>> yy[1]
[2.0 +/- 5.0]
>>> yy[1].value
array(2.)
>>> yy[1].error
array(5.)
>>>