def test_vector_heat_2d_sub(): """ Test __sub__ """ vector_heat_2d_1 = VectorHeat2D(nx=3, ny=3) vector_heat_2d_1.values = np.ones((3, 3)) vector_heat_2d_2 = VectorHeat2D(nx=3, ny=3) vector_heat_2d_2.values = 2 * np.ones((3, 3)) vector_heat_2d_res = vector_heat_2d_2 - vector_heat_2d_1 np.testing.assert_equal(vector_heat_2d_res.values, np.ones((3, 3)))
def test_vector_heat_2d_add(): """ Test __add__ """ vector_heat_2d_1 = VectorHeat2D(nx=3, ny=3) vector_heat_2d_1.values = np.ones((3, 3)) vector_heat_2d_2 = VectorHeat2D(nx=3, ny=3) vector_heat_2d_2.values = 2 * np.ones((3, 3)) vector_heat_2d_res = vector_heat_2d_1 + vector_heat_2d_2 np.testing.assert_equal(vector_heat_2d_res.values, 3 * np.ones((3, 3)))
def test_vector_heat_2d_set_values(): """ Test the set_values() """ vector_heat_2d = VectorHeat2D(nx=3, ny=3) vector_heat_2d.set_values(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])) np.testing.assert_equal(vector_heat_2d.values, np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]))
def test_vector_heat_2d_constructor(): """ Test constructor """ vector_heat_2d = VectorHeat2D(nx=3, ny=3) np.testing.assert_equal(vector_heat_2d.nx, 3) np.testing.assert_equal(vector_heat_2d.ny, 3) np.testing.assert_equal(vector_heat_2d.values, np.zeros((3, 3)))
def test_vector_heat_2d_norm(): """ Test norm() """ vector_heat_2d = VectorHeat2D(nx=3, ny=3) vector_heat_2d.values = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) np.testing.assert_equal( np.linalg.norm(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])), vector_heat_2d.norm())
def test_vector_heat_2d_clone_rand(): """ Test clone_rand() """ vector_heat_2d = VectorHeat2D(nx=3, ny=3) vector_heat_2d_clone = vector_heat_2d.clone_rand() np.testing.assert_equal(True, isinstance(vector_heat_2d_clone, VectorHeat2D)) np.testing.assert_equal(np.size(vector_heat_2d_clone.values), 9)
def test_vector_heat_2d_clone_zero(): """ Test clone_zero() """ vector_heat_2d = VectorHeat2D(nx=3, ny=3) vector_heat_2d_clone = vector_heat_2d.clone_zero() np.testing.assert_equal(True, isinstance(vector_heat_2d_clone, VectorHeat2D)) np.testing.assert_equal(vector_heat_2d_clone.values, np.zeros((3, 3))) np.testing.assert_equal(vector_heat_2d_clone.nx, 3) np.testing.assert_equal(vector_heat_2d_clone.ny, 3)
def test_vector_heat_2d_get_values(): """ Test get_values() """ vector_heat_2d = VectorHeat2D(nx=3, ny=3) np.testing.assert_equal(vector_heat_2d.get_values(), np.zeros((3, 3)))