``````

In [1]:

import numpy as np

``````
``````

In [2]:

a = np.array([0.3, 0.1 + 0.1 + 0.1])
print(a)

``````
``````

[0.3 0.3]

``````
``````

In [3]:

b = np.array([0.3, 0.3])
print(b)

``````
``````

[0.3 0.3]

``````
``````

In [4]:

c = np.array([0.2, 0.3])
print(c)

``````
``````

[0.2 0.3]

``````
``````

In [5]:

print(np.allclose(a, b))

``````
``````

True

``````
``````

In [6]:

print(np.allclose(a, c))

``````
``````

False

``````
``````

In [7]:

a_100 = np.array([99, 100, 101])
print(a_100)

``````
``````

[ 99 100 101]

``````
``````

In [8]:

print(np.allclose(a_100, 100))

``````
``````

False

``````
``````

In [9]:

print(np.allclose(a_100, 100, rtol=0, atol=1))

``````
``````

True

``````
``````

In [10]:

a_nan = np.array([np.nan, 1, 2])
print(a_nan)

``````
``````

[nan  1.  2.]

``````
``````

In [11]:

b_nan = np.array([np.nan, 1, 2])
print(b_nan)

``````
``````

[nan  1.  2.]

``````
``````

In [12]:

print(np.allclose(a_nan, b_nan))

``````
``````

False

``````
``````

In [13]:

print(np.allclose(a_nan, b_nan, equal_nan=True))

``````
``````

True

``````