python - How to avoid bug in numpy.place while calculating inverse cumulative distribution function of large numpy array? -
i have come across bug in scipy or numpy, has seen following issue or has workaround?
from scipy.stats import distributions import numpy np distributions.norm.ppf(np.ones((30000, 10000)) / 2.0)
results in
array([[ 0., 0., 0., ..., 0., 0., 0.], [ 0., 0., 0., ..., 0., 0., 0.], [ 0., 0., 0., ..., 0., 0., 0.], ..., [ nan, nan, nan, ..., nan, nan, nan], [ nan, nan, nan, ..., nan, nan, nan], [ nan, nan, nan, ..., nan, nan, nan]])
smaller runs (like 20000 rows) work fine.
using numpy 1.10.4.
edit
problems seems deeper, appearing inside numpy:
na = np.zeros((30000, 10000)) * np.nan np.place(na, np.ones((30000, 10000)), np.ravel(np.ones((30000, 10000))))
resulting in
array([[ 1., 1., 1., ..., 1., 1., 1.], [ 1., 1., 1., ..., 1., 1., 1.], [ 1., 1., 1., ..., 1., 1., 1.], ..., [ nan, nan, nan, ..., nan, nan, nan], [ nan, nan, nan, ..., nan, nan, nan], [ nan, nan, nan, ..., nan, nan, nan]])
added bug report: https://github.com/numpy/numpy/issues/7207
the problem seems integer overflow happening within arr_insert_loop
function in numpy/core/src/multiarray/compiled_base.c
. i've opened pull request should fix issue.
Comments
Post a Comment