コード例 #1
0
def test_named_arguments():
    a = np.array([[1.0, 2], [3, 4], [5, 6]])
    b = np.ones((2, 1))

    assert np.all(m.matrix_multiply(a, b) == np.array([[3.], [7], [11]]))
    assert np.all(m.matrix_multiply(A=a, B=b) == np.array([[3.], [7], [11]]))
    assert np.all(m.matrix_multiply(B=b, A=a) == np.array([[3.], [7], [11]]))

    with pytest.raises(ValueError) as excinfo:
        m.matrix_multiply(b, a)
    assert str(excinfo.value) == 'Nonconformable matrices!'

    with pytest.raises(ValueError) as excinfo:
        m.matrix_multiply(A=b, B=a)
    assert str(excinfo.value) == 'Nonconformable matrices!'

    with pytest.raises(ValueError) as excinfo:
        m.matrix_multiply(B=a, A=b)
    assert str(excinfo.value) == 'Nonconformable matrices!'
コード例 #2
0
ファイル: test_eigen.py プロジェクト: Soolo-ss/Solo2
def test_named_arguments():
    a = np.array([[1.0, 2], [3, 4], [5, 6]])
    b = np.ones((2, 1))

    assert np.all(m.matrix_multiply(a, b) == np.array([[3.], [7], [11]]))
    assert np.all(m.matrix_multiply(A=a, B=b) == np.array([[3.], [7], [11]]))
    assert np.all(m.matrix_multiply(B=b, A=a) == np.array([[3.], [7], [11]]))

    with pytest.raises(ValueError) as excinfo:
        m.matrix_multiply(b, a)
    assert str(excinfo.value) == 'Nonconformable matrices!'

    with pytest.raises(ValueError) as excinfo:
        m.matrix_multiply(A=b, B=a)
    assert str(excinfo.value) == 'Nonconformable matrices!'

    with pytest.raises(ValueError) as excinfo:
        m.matrix_multiply(B=a, A=b)
    assert str(excinfo.value) == 'Nonconformable matrices!'