Testing Class Material
This commit is contained in:
commit
05b1f6cdd5
85 changed files with 102796 additions and 0 deletions
23
hands_on_solutions/numpy_equality/test_numpy_equality.py
Normal file
23
hands_on_solutions/numpy_equality/test_numpy_equality.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import numpy as np
|
||||
from numpy.testing import assert_allclose, assert_equal
|
||||
|
||||
|
||||
def test_equality():
|
||||
x = np.array([1, 1])
|
||||
y = np.array([2, 2])
|
||||
z = np.array([3, 3])
|
||||
assert_equal(x + y, z)
|
||||
|
||||
|
||||
def test_equality_with_nan():
|
||||
x = np.array([1, np.nan])
|
||||
y = np.array([2, np.nan])
|
||||
z = np.array([3, np.nan])
|
||||
assert_equal(x + y, z)
|
||||
|
||||
|
||||
def test_allclose_with_nan():
|
||||
x = np.array([1.1, np.nan])
|
||||
y = np.array([2.2, np.nan])
|
||||
z = np.array([3.3, np.nan])
|
||||
assert_allclose(x + y, z)
|
Loading…
Add table
Add a link
Reference in a new issue