In [1]:
import numpy as np
In [2]:
a = np.array([0.3, 0.1 + 0.1 + 0.1])
print(a)
In [3]:
b = np.array([0.3, 0.3])
print(b)
In [4]:
c = np.array([0.2, 0.3])
print(c)
In [5]:
print(np.allclose(a, b))
In [6]:
print(np.allclose(a, c))
In [7]:
a_100 = np.array([99, 100, 101])
print(a_100)
In [8]:
print(np.allclose(a_100, 100))
In [9]:
print(np.allclose(a_100, 100, rtol=0, atol=1))
In [10]:
a_nan = np.array([np.nan, 1, 2])
print(a_nan)
In [11]:
b_nan = np.array([np.nan, 1, 2])
print(b_nan)
In [12]:
print(np.allclose(a_nan, b_nan))
In [13]:
print(np.allclose(a_nan, b_nan, equal_nan=True))