I experienced a RuntimeWarning
RuntimeWarning: invalid value encountered in less_equal
Generated by this line of code of mine:
Adding to the above answers another way to suppress this warning is to use numpy.less explicitly, supplying the where and out parameters:
np.less([1, 2], [2, np.nan])
outputs: array([ True, False]) causing the runtime warning,
np.less([1, 2], [2, np.nan], where=np.isnan([2, np.nan])==False)
does not calculate result for the 2nd array element according to the docs leaving the value undefined (I got True output for both elements), while
np.less([1, 2], [2, np.nan], where=np.isnan([2, np.nan])==False, out=np.full((1, 2), False)
writes the result into an array pre-initilized to False (and so always gives False in the 2nd element).