def test_transpose():
    m1 = MyMatrix(a)
    m2 = MyMatrix(c)
    m1.transpose()
    m2.transpose()
    assert (m1.get_data() == [[2, 1, 0], [2, 1, 4]])
    assert (m2.get_data() == [])
def test_transpose():
    zero_matrix = MyMatrix([])
    matrix = MyMatrix([[1, 2], [5, 6], [4, 7]])
    matrix.transpose()
    assert (matrix.size() == (2, 3))
    assert (matrix.get_data() == [[1, 5, 4], [2, 6, 7]])
    assert (zero_matrix.transpose().get_data() == [])
示例#3
0
def test_transpose():
    data = [[1, 2, 3], [4, 5, 6]]
    matrix = MyMatrix([[1, 2, 3], [4, 5, 6]])
    matrix.transpose()
    assert (matrix.get_data() == [[1, 4], [2, 5], [3, 6]])
    assert (matrix.size() == (3, 2))
    empty_matrix = MyMatrix([])
    empty_matrix.transpose()
    assert (empty_matrix.size() == (0, 0))
    assert (empty_matrix.get_data() == [])
示例#4
0
def test_transpose():
    matrix = MyMatrix(some_matrix)
    matrix = matrix.transpose()
    assert (matrix.size() == (2, 3))
    assert (matrix.get_data() == [[1, 3, 5], [2, 4, 6]])

    empty_matrix = MyMatrix([])
    empty_matrix.transpose()
    assert (empty_matrix.size() == (0, 0))
    assert (empty_matrix.get_data() == [])
示例#5
0
def test_transpose():
    matrix = MyMatrix([[1, 2, 3, 4], [5, 6, 7, 8]])
    matrix.transpose()
    assert (matrix.size() == (4, 2))
    #AssertionError
    assert (matrix.get_data() == [[1, 5], [2, 6], [3, 7], [4, 8]])
    empty_matrix = MyMatrix(c)
    empty_matrix.transpose()
    assert (empty_matrix.size() == (0, 0))
    assert (empty_matrix.get_data() == [])
示例#6
0
def test_transpose():
    mymatrix = MyMatrix([[1, 2], [3, 4]])
    mymatrix.transpose()
    mymatrix.transposed()
    assert (repr(mymatrix) == '1 3\n2 4')
    assert (mymatrix.size() == (2, 2))
    mymatrix = MyMatrix([[1, 2, 3, 4], [5, 6, 7, 8]])
    mymatrix.transpose()
    mymatrix.transposed()
    assert (mymatrix.size() == (4, 2))
    assert (repr(mymatrix) == '1 5\n2 6\n3 7\n4 8')
    mymatrix = MyMatrix([[0, 2], [3, 0]])
    mymatrix.transpose()
    assert (repr(mymatrix) == '0 3\n2 0')
    mymatrix = MyMatrix([[0], [0]])
    mymatrix.flip_left_right()
    assert (repr(mymatrix) == '0\n0')
示例#7
0
def test_transpose():
    matrix = MyMatrix([[1, 2, 3], [4, 5, 6]])
    assert (matrix.transpose()._get_data() == [[1, 4], [2, 5], [3, 6]])
    assert (repr(matrix) == '1 4 \n2 5 \n3 6')
    matrix = MyMatrix([[1, 2], [3, 4], [5, 6]])
    assert (matrix.transpose()._get_data() == [[1, 3, 5], [2, 4, 6]])