[Numpy-discussion] proposal of new keywords for np.nan_to_num
allanhaldane at gmail.com
Mon Apr 8 11:39:31 EDT 2019
Since there seem to be no objections, I think we're going ahead with
this enhancement for np.nan_to_num.
On 4/4/19 1:11 PM, kikocorreoso wrote:
> Hi all,
> I propose to add some keywords to nan_to_num function. The addition do
> not modify the actual behavior. Information related with this addition
> can be found in these links:
> The basic idea is to allow the user to use their own defined values when
> replacing nan, positive infinity and/or negative infinity. The proposed
> names for the keywords are 'nan', posinf', and 'neginf' respectively. So
> the usage would be something like this:
>>>> a = np.array((np.nan, 2, 3, np.inf, 4, 5, -np.inf))
>>>> np.nan_to_num(a, nan=-999)
> array([-9.99000000e+002, 2.00000000e+000, 3.00000000e+000,
> 1.79769313e+308, 4.00000000e+000, 5.00000000e+000,
>>>> np.nan_to_num(a, posinf=np.nan, neginf=np.nan)
> array([ 0., 2., 3., nan, 4., 5., nan])
> Please, could you comment if it would be useful the addition?, if the PR
> needs any change?...
> Thanks to Eric, Joseph, Allan and Matti for their comments and revisions
> on GH.
> Kind regards.
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
More information about the NumPy-Discussion