On Wed, Nov 20, 2013 at 9:09 AM, Daπid <davidmen...@gmail.com> wrote:
> I have the following code, operating on some arrays. > > pen = 1 - (real_sum[int(i1 + t)]) / (absolute[int(i1 + t)]) > if np.isnan(pen): > pen = 0.0 > > I know that, sometimes, real_sum and absolute are 0 at the designated > point, so I should get a RuntimeWarning. But, the warning is puzzling: > > RuntimeWarning: invalid value encountered in double_scalars > pen = 0.0 > > Is the warning actually being raised at that point? Or can I not really > trust the line reported by the warning? I have tried to replicate it in > interactive terminal, but without luck, I always get it in the previous > line. > > > I am using Python 2.7 and Numpy 1.8.0. > > > /David. > > This can sometimes happen in very weird edge cases of development workflows. Essentially, if one edits the source code while the module is still loaded in the python session, the line numbers recorded in the *.pyc files diverge from the source code. The warning that is emitted checks the source code at that time to print out the relevant line. Maybe that might explain what is happening here? Ben Root
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion