Exemple #1
0
    def test_create_from_matrix(self):
        m = Matrix.from_matrix([
            [1, 2],
            [3, 4],
            [5, 6],
        ])

        self.assertEqual(m.row(0), [1, 2])
        self.assertEqual(m.row(1), [3, 4])
        self.assertEqual(m.row(2), [5, 6])

        self.assertEqual(m.column(0), [1, 3, 5])
        self.assertEqual(m.column(1), [2, 4, 6])
Exemple #2
0
 def __init__(self, matrix=[], shape=None):
     if shape:
         x, y = shape
         self.matrix = Matrix.from_shape(x=x, y=y, default=-1)
     else:
         self.matrix = Matrix.from_matrix(matrix)