MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / test_subtraction

Function test_subtraction

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

Source from the content-addressed store, hash-verified

56 ("mat1", "mat2"), [(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]
57)
58def test_subtraction(mat1, mat2):
59 if (np.array(mat1)).shape < (2, 2) or (np.array(mat2)).shape < (2, 2):
60 logger.info(f"\n\t{test_subtraction.__name__} returned integer")
61 with pytest.raises(TypeError):
62 matop.subtract(mat1, mat2)
63 elif (np.array(mat1)).shape == (np.array(mat2)).shape:
64 logger.info(f"\n\t{test_subtraction.__name__} with same matrix dims")
65 act = (np.array(mat1) - np.array(mat2)).tolist()
66 theo = matop.subtract(mat1, mat2)
67 assert theo == act
68 else:
69 logger.info(f"\n\t{test_subtraction.__name__} with different matrix dims")
70 with pytest.raises(ValueError):
71 assert matop.subtract(mat1, mat2)
72
73
74@pytest.mark.mat_ops

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected