MAINT: replace np.isinf(x) & (x>0) -> np.isposinf(x) to avoid RuntimeWarning #3381

Merged
merged 1 commit into from Feb 24, 2014

Conversation

Projects
None yet
4 participants
Contributor

argriffing commented Feb 24, 2014

This fixes warnings of the type

scipy/special/_testutils.py", line 244, in check
    pinf_x = np.isinf(x) & (x > 0)
RuntimeWarning: invalid value encountered in greater

and is less complicated.

>>> import numpy as np
>>> a = np.nan
>>> b = np.inf
>>> c = -np.inf
>>> d = 4
>>> e = np.array([a, b, c, d])
>>> for x in (a, b, c, d, e): print np.isposinf(x)
... 
False
True
False
False
[False  True False False]
>>> for x in (a, b, c, d, e): print np.isinf(x) & (x > 0)
... 
False
True
False
False
__main__:1: RuntimeWarning: invalid value encountered in greater
[False  True False False]

This fix is pillaged from #3370.

pv added the PR label Feb 24, 2014

@pv pv added a commit that referenced this pull request Feb 24, 2014

@pv pv Merge pull request #3381 from argriffing/testutils-signed-inf
MAINT: replace np.isinf(x) & (x>0) -> np.isposinf(x) to avoid RuntimeWarning
6dc9dce

@pv pv merged commit 6dc9dce into scipy:master Feb 24, 2014

1 check was pending

default The Travis CI build is in progress
Details
Owner

pv commented Feb 24, 2014

Thanks, LGTM

rgommers added this to the 0.14.0 milestone Feb 24, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment