Ejemplo n.º 1
0
def test_flip_left_right():
    m1 = MyMatrix(a)
    m2 = MyMatrix(c)
    m1.flip_left_right()
    m2.flip_left_right()
    assert (m1.get_data() == [[2, 2], [1, 1], [4, 0]])
    assert (m2.get_data() == [])
Ejemplo n.º 2
0
def test_flip_left_right():
    matrix = MyMatrix([[1, 2, 3], [4, 5, 6]])
    m = matrix.flip_left_right()
    empty_matrix = MyMatrix([])
    assert (m.get_data() == [[3, 2, 1], [6, 5, 4]])
    empty_matrix.flip_left_right()
    assert (empty_matrix.get_data() == [])
Ejemplo n.º 3
0
def test_flipped_left_right():
    matrix = MyMatrix(some_matrix)
    new_matrix = matrix.flipped_left_right()
    assert (new_matrix.size() == (3, 2))
    assert (new_matrix.get_data() == [[2, 1], [4, 3], [6, 5]])

    empty_matrix = MyMatrix([])
    empty_matrix.flip_left_right()
    assert (empty_matrix.size() == (0, 0))
    assert (empty_matrix.get_data() == [])
Ejemplo n.º 4
0
def test_flipped_up_down():
    some_list = [[4, 5, 6], [1, 2, 3]]
    m1 = MyMatrix(some_list)
    m2 = m1.flipped_up_down()
    assert (m2.get_data() == [[1, 2, 3], [4, 5, 6]])
    assert (m1.get_data() == [[4, 5, 6], [1, 2, 3]])

    empty_matrix = MyMatrix([])
    empty_matrix.flip_left_right()
    assert (empty_matrix.size() == (0, 0))
    assert (empty_matrix.get_data() == [])
Ejemplo n.º 5
0
def test_size():
    mymatrix = MyMatrix([[1, 2], [3, 4]])
    mymatrix.flip_up_down()
    mymatrix.flip_left_right()
    assert (mymatrix.size() == (2, 2))
    mymatrix = MyMatrix([[1, 2, 3], [4, 5, 6]])
    assert (mymatrix.size() == (2, 3))
    mymatrix = MyMatrix([[-1, 556], [989, -4]])
    assert (mymatrix.size() == (2, 2))
    mymatrix = MyMatrix([[], []])
    assert (mymatrix.size() == (2, 0))
Ejemplo n.º 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')
Ejemplo n.º 7
0
def test_flip_left_right():
    mymatrix = MyMatrix([[1, 2], [3, 4]])
    mymatrix.flip_left_right()
    assert (repr(mymatrix) == '2 1\n4 3')
    assert (mymatrix.size() == (2, 2))
    mymatrix = MyMatrix([[1, 2, 3, 4], [5, 6, 7, 8]])
    mymatrix.flip_left_right()
    assert (repr(mymatrix) == '4 3 2 1\n8 7 6 5')
    assert (mymatrix.size() == (2, 4))
    mymatrix = MyMatrix([[0, 2], [3, 0]])
    mymatrix.flip_left_right()
    assert (repr(mymatrix) == '2 0\n0 3')
    mymatrix = MyMatrix([[0], [0]])
    mymatrix.flip_left_right()
    assert (repr(mymatrix) == '0\n0')
Ejemplo n.º 8
0
def test_flip_left_right():
    zero_matrix = MyMatrix([])
    matrix = MyMatrix([[1, 2], [5, 6], [4, 7]])
    assert (matrix.flip_left_right().get_data() == [[2, 1], [6, 5], [7, 4]])
    assert (zero_matrix.flip_left_right().get_data() == [])
Ejemplo n.º 9
0
def test_flip_left_right():
    some_list = [[4, 5, 6], [1, 2, 3]]
    m = MyMatrix(some_list)
    m.flip_left_right()
    assert (m.get_data() == [[6, 5, 4], [3, 2, 1]])
Ejemplo n.º 10
0
def test_flip_left_right():
    matrix = MyMatrix([[1, 2, 3], [4, 5, 6]])
    assert (matrix.flip_left_right()._get_data() == [[3, 2, 1], [6, 5, 4]])
    assert (repr(matrix) == '3 2 1 \n6 5 4')
    matrix = MyMatrix([[1, 2], [3, 4], [5, 6]])
    assert (matrix.flip_left_right()._get_data() == [[2, 1], [4, 3], [6, 5]])
Ejemplo n.º 11
0
def test_flip_left_right():
    matrix = MyMatrix(a)
    matrix.flip_left_right()
    assert (matrix.get_data() == [[2, 1], [4, 3], [5, 4]])
    empty_matrix = MyMatrix(c)
    assert (empty_matrix.get_data() == [])