Finding the calculation that generates a NaN Finding the calculation that generates a NaN numpy numpy

Finding the calculation that generates a NaN


I would start with numpy.seterr.

There, an invalid operation is defined as "result is not an expressible number, typically indicates that a NaN was produced". By default, this seems to be set to "ignore".


You can use numpy.seterr to set floating point error handling behaviour globally for all numpy routines. That should let you pinpoint where in the code they are arising from (or a least where numpy see them for the first time).