Exemplo n.º 1
0
def test_vector_matrix_wrong_format_2():
    matrix = [[0, 44, 0, 12], [0, 0], [21, 0, 0, 0]]
    vector = [[2], [0], [0]]
    with pytest.raises(
            ValueError,
            match=r"Wrong inputs. Matrix must be mxn or nxn and vector 1xn."):
        multiply_vector_matrix(matrix, vector)
Exemplo n.º 2
0
def test_vector_matrix_3():
    matrix = [[0, 44, 0, 12], [0, 0, 0, 0], [21, 0, 0, 0]]
    vector = [[0, 0, 0]]
    ar, ia, ja = multiply_vector_matrix(matrix, vector)
    assert ar == []
    assert ia == [0, 0]
    assert ja == []
Exemplo n.º 3
0
def test_vector_matrix_2():
    matrix = [[0, 44, 0, 12], [0, 0, 0, 0], [21, 0, 0, 0]]
    vector = [[2, 0, 4]]
    ar, ia, ja = multiply_vector_matrix(matrix, vector)
    assert ar == [84, 88, 24]
    assert ia == [0, 3]
    assert ja == [0, 1, 3]
Exemplo n.º 4
0
def test_vector_matrix_empty_vector():
    matrix = [[0, 44, 0, 12], [0, 0, 0, 0], [21, 0, 0, 0]]
    vector = []
    with pytest.raises(ValueError, match=r"Empty vector was given"):
        multiply_vector_matrix(matrix, vector)
Exemplo n.º 5
0
def test_vector_matrix_wrong_format_3():
    matrix = [[0, 44, 0, 12], [0, 0, 0], [21, 0, 0, 0]]
    vector = [[2, 0, 4]]
    with pytest.raises(ValueError,
                       match=r"All matrix's rows must have equal length"):
        multiply_vector_matrix(matrix, vector)