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:
https://github.com/numpy/numpy/pull/13219
https://github.com/numpy/numpy/pull/9355
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,
-1.79769313e+308])
>>> 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@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion