8000 numpy.linalg.norm returns nan for an array of int16 · Issue #6128 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
numpy.linalg.norm returns nan for an array of int16 #6128
Closed
@WarrenWeckesser

Description

@WarrenWeckesser

Example:

In [1]: np.__version__
Out[1]: '1.10.0.dev0+a92c4a1'

In [2]: x = np.array([ -91, -119, -137, -132], dtype=np.int16)

In [3]: np.linalg.norm(x)
/Users/warren/local_scipy/lib/python2.7/site-packages/numpy/linalg/linalg.py:2126: RuntimeWarning: invalid value encountered in sqrt
  ret = sqrt(sqnorm)
Out[3]: nan

The example is from http://stackoverflow.com/questions/31685156/normalizing-vector-produces-nan-in-numpy, although it is not clear in that question if the array has type int16.

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

      0