varchasgopalaswamy / AutoUncertainties

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

Is it possible to create Uncertainty array from an Uncertainty array? #4

Open MichaelTiemannOSC opened 1 year ago

MichaelTiemannOSC commented 1 year ago

I can create an uncertainty array from a pair of arrays, one representing nominal values and one representing error values. However, I cannot seem to figure out how to pass a list or array of Uncertainty values to create a new np.array of Uncertainty values.

Indeed, this implementation of array seems to prevent such:

    def __array__(self, t=None) -> np.ndarray:
        warnings.warn(
            "The uncertainty is stripped when downcasting to ndarray.",
            NumpyDowncastWarning,
            stacklevel=2,
        )
        return np.asarray(self._nom)

ndarrays can hold object types (which is what makes PintArrays) work.