Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Patch to fix behavior of numpy.sign(numpy.nan) (Trac #794) #1392

Closed
@numpy-gitbot

Description

@numpy-gitbot

Original ticket http://projects.scipy.org/numpy/ticket/794 on 2008-05-17 by trac user brorson, assigned to @charris.

As was discussed on numpy-discuss earlier today, I am submitting a patch to fix the behavior of numpy.sign(numpy.nan). With this patch, the following behavior obtains:

>>> R = numpy.array([-numpy.inf, -2, 0, 2, numpy.inf, numpy.nan])
>>> numpy.sign(R)
array([ -1.,  -1.,   0.,   1.,   1.,  NaN])
>>>
>>> C = numpy.array([-numpy.inf, -2+1j, 0, 2-1j, numpy.inf, numpy.nan])
>>> numpy.sign(C)
array([ -1.+0.j,  -1.+0.j,   0.+0.j,   1.+0.j,   1.+0.j,  NaN+0.j])

Cheers,

Stuart Brorson[[BR]]
Interactive Supercomputing, inc.[[BR]]
135 Beaver Street | Waltham | MA | 02452 | USA[[BR]]
http://www.interactivesupercomputing.com/[[BR]]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions