ans[np.isnan(ans) == True] = 0.0  is a double comparison

same as
ans[np.isnan(ans)] = 0.0