def squish_infinite(x, range=(<NUM_LIT:0>, <NUM_LIT:1>)):
xtype = type(x)<EOL>if not hasattr(x, '<STR_LIT>'):<EOL><INDENT>x = np.asarray(x)<EOL><DEDENT>x[x == -np.inf] = range[<NUM_LIT:0>]<EOL>x[x == np.inf] = range[<NUM_LIT:1>]<EOL>if not isinstance(x, xtype):<EOL><INDENT>x = xtype(x)<EOL><DEDENT>return x<EOL>
Truncate infinite values to a range.

Parameters
----------
x : array_like
    Values that should have infinities squished.
range : tuple
    The range onto which to squish the infinites.
    Must be of size 2.

Returns
-------
out : array_like
    Values with infinites squished.

Examples
--------
>>> squish_infinite([0, .5, .25, np.inf, .44])
[0.0, 0.5, 0.25, 1.0, 0.44]
>>> squish_infinite([0, -np.inf, .5, .25, np.inf], (-10, 9))
[0.0, -10.0, 0.5, 0.25, 9.0]