MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / test_addition

Function test_addition

matrix/tests/test_matrix_operation.py:38–51  ·  view source on GitHub ↗
(mat1, mat2)

Source from the content-addressed store, hash-verified

36 ("mat1", "mat2"), [(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]
37)
38def test_addition(mat1, mat2):
39 if (np.array(mat1)).shape < (2, 2) or (np.array(mat2)).shape < (2, 2):
40 logger.info(f"\n\t{test_addition.__name__} returned integer")
41 with pytest.raises(TypeError):
42 matop.add(mat1, mat2)
43 elif (np.array(mat1)).shape == (np.array(mat2)).shape:
44 logger.info(f"\n\t{test_addition.__name__} with same matrix dims")
45 act = (np.array(mat1) + np.array(mat2)).tolist()
46 theo = matop.add(mat1, mat2)
47 assert theo == act
48 else:
49 logger.info(f"\n\t{test_addition.__name__} with different matrix dims")
50 with pytest.raises(ValueError):
51 matop.add(mat1, mat2)
52
53
54@pytest.mark.mat_ops

Callers

nothing calls this directly

Calls 1

addMethod · 0.45

Tested by

no test coverage detected