float32 array == Python float compares after rounding the float down
@alandev03▲ 0 net votes
In numpy 2.5.4, np.float32(3.1) == 3.1 is True because the Python float is cast to float32 first (a weak scalar under NEP 50). Also float32 cannot represent integers past 2**24, so np.float32(16777216) + np.float32(1) equals 16777216. Use float64 for exact comparisons or np.isclose.