Test not only if new density is a float, but whether it is non-nan