Here are the examples of the python api numpy.isposinf taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
0
Example 1
Project: scikit-rf Source File: mathFunctions.py
def inf_to_num(x):
'''
converts inf and -inf's to large numbers
Parameters
------------
x : array-like or number
the input array or number
Returns
-------
'''
#TODO: make this valid for complex arrays
try:
x[npy.isposinf(x)] = INF
x[npy.isneginf(x)] = -1*INF
except(TypeError):
x = npy.array(x)
x[npy.isposinf(x)] = INF
x[npy.isneginf(x)] = -1*INF
0
Example 2
Project: geostatsmodels Source File: zscoretrans.py
def to_norm( data ):
'''
Input (data) 1D NumPy array of observational data
Output (z) 1D NumPy array of z-score transformed data
(inv) inverse mapping to retrieve original distribution
'''
# look at the dimensions of the data
dims = data.shape
# if there is more than one dimension..
if len( dims ) > 1:
# take the third column of the second dimension
z = data[:,2]
# otherwise just use data as is
else:
z = data
# grab the number of data points
N = len( z )
# grab the cuemulative distribution function
f, inv = cdf( z )
# h will return the cdf of z
# by interpolating the mapping f
h = fit( f )
# ppf will return the inverse cdf
# of the standard normal distribution
ppf = scipy.stats.norm(0,1).ppf
# for each data point..
for i in range( N ):
# h takes z to a value in [0,1]
p = h( z[i] )
# ppf takes p (in [0,1]) to a z-score
z[i] = ppf( p )
# convert positive infinite values
posinf = np.isposinf( z )
z = np.where( posinf, np.nan, z )
z = np.where( np.isnan( z ), np.nanmax( z ), z )
# convert negative infinite values
neginf = np.isneginf( z )
z = np.where( neginf, np.nan, z )
z = np.where( np.isnan( z ), np.nanmin( z ), z )
# if the whole data set was passed, then add the
# transformed variable and recombine with data
if len( dims ) > 1:
z = np.vstack(( data[:,:2].T, z )).T
return z, inv
0
Example 3
Project: scikit-aero Source File: test_isentropic.py
def test_area_ratio_no_zero_division_error():
fl = isentropic.IsentropicFlow()
assert np.isposinf(fl.A_Astar(0))