In my simulation, when reaching such an expression of a function inside a for loop:
d1ToUse = d2Weights[:,i] > 1e-9
a warning is sometimes thrown:
RuntimeWarning: invalid value encountered in greater...
I would like to print out the value of the 'greater' whenever this warning is thrown in order to inspect the variable d2Weights and eliminate the problem.
For some instantiations of this warning, the d2Weights variable was an empty list. I have tried to eliminate those instantiations from the analysis by filtering them out by any of the following filters:
if d2Weights[:,i] == []:
continue
if np.any(d2Weights[:, i] == None):
continue
if np.any(d2Weights[:, i] == np.nan):
continue
if sum(d2Weights[d1ToUse, i]) == 0.0:
continue
if d2Weights[d1ToUse, i] is None:
continue
if np.any(d2Weights[d1ToUse, i] == None):
continue
if np.any(d2Weights[d1ToUse, i] == np.nan):
continue
As the problem lingers, I would like to see how the 'greater' value looks to inspect it and identify the root cause.
I do NOT want to suppress this warning because whenever it is thrown, my simulation behaves weirdly.
I will be grateful for any suggestion.
EDIT:
d2Weights is numpy array with floats. It stores weights for circular weighted averaging with RBF kernel.