Skip to content

norm of vector with uncertainties #121

@karlwessel

Description

@karlwessel

Calculating the norm of a numpy array with uncertainties using numpy.linalg.norm throws an error which can be reproduced with the following MWE:

from uncertainties import unumpy
import numpy
a = unumpy.uarray([1, 1], [1, 1])
numpy.linalg.norm(unumpy.nominal_values(a)) # works fine
numpy.linalg.norm(a)

This throws the following exception:

AttributeError: 'AffineScalarFunc' object has no attribute 'sqrt'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<__array_function__ internals>", line 6, in norm
  File "lib/python3.6/site-packages/numpy/linalg/linalg.py", line 2483, in norm
    ret = sqrt(sqnorm)
TypeError: loop of ufunc does not support argument 0 of type AffineScalarFunc which has no callable sqrt method

This is with uncertainties version 3.1.2 and numpy version 1.17.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions