I experienced a RuntimeWarning
RuntimeWarning: invalid value encountered in less_equal
Generated by this line of code of mine:
As a follow-up to Divakar's answer and his comment on how to suppress the RuntimeWarning, a safer way is suppressing them only locally using with np.errstate() (docs): it is good to generally be alerted when comparisons to np.nan yield False, and ignore the warning only when this is really what is intended. Here for the OP's example:
with np.errstate(invalid='ignore'):
center_dists[j] <= center_dists[i]
Upon exiting the with block, error handling is reset to what it was before.
Instead of invalid value encountered, one can also ignore all errors by passing all='ignore'. Interestingly, this is missing from the kwargs in the docs for np.errstate(), but not in the ones for np.seterr(). (Seems like a small bug in the np.errstate() docs.)