Ejemplo n.º 1
0
    def test_should_multiply_itself_by_10x10_matrix(self):
        matrix = Matrix(10, 10, 2)
        other_matrix = Matrix(10, 10, 1337)

        matrix.multiply(other_matrix)

        self.assertEquals(2 * 1337, matrix.get_item(9, 9))
Ejemplo n.º 2
0
    def test_should_substract_other_10x10_matrix(self):
        matrix = Matrix(10, 10, 1338)
        other_matrix = Matrix(10, 10, 1)

        matrix.subtract(other_matrix)

        self.assertEquals(1337, matrix.get_item(9, 9))
Ejemplo n.º 3
0
    def test_should_multiply_itself_by_1x1_matrix(self):
        matrix = Matrix(1, 1, 2)
        other_matrix = Matrix(1, 1, 1337)

        matrix.multiply(other_matrix)

        self.assertEquals(2 * 1337, matrix.get_item(0, 0))
Ejemplo n.º 4
0
    def test_should_substract_other_1x1_matrix(self):
        matrix = Matrix(1, 1, 1338)
        other_matrix = Matrix(1, 1, 1)

        matrix.subtract(other_matrix)

        self.assertEquals(1337, matrix.get_item(0, 0))
Ejemplo n.º 5
0
    def test_should_add_itself_to_other_10x10_matrix(self):
        matrix = Matrix(10, 10, 1)
        other_matrix = Matrix(10, 10, 1336)

        matrix.add(other_matrix)

        self.assertEquals(1337, matrix.get_item(9, 9))
Ejemplo n.º 6
0
    def test_should_add_itself_to_other_1x1_matrix(self):
        matrix = Matrix(1, 1, 1)
        other_matrix = Matrix(1, 1, 1336)

        matrix.add(other_matrix)

        self.assertEquals(1337, matrix.get_item(0, 0))
Ejemplo n.º 7
0
    def test_should_contain_1337_in_last_row_after_transpose(self):
        cols = 100
        rows = 1
        matrix = Matrix(cols, rows, 1)
        val = 1337
        matrix.set_item(cols - 1, 0, val)

        matrix.transpose()

        self.assertEquals(val, matrix.get_item(0, cols - 1))
Ejemplo n.º 8
0
    def should_scale_by_factor(self, factor):
        matrix = Matrix(1, 1, 1)

        matrix.scale_by(factor)

        self.assertEquals(factor, matrix.get_item(0, 0))
Ejemplo n.º 9
0
    def test_should_set_and_get_second_row_of_second_column(self):
        matrix = Matrix(2, 2)
        val = 1
        matrix.set_item(1, 1, val)

        self.assertEquals(val, matrix.get_item(1, 1))
Ejemplo n.º 10
0
    def test_should_set_and_get_first_row_of_first_column(self):
        matrix = Matrix(1, 1)
        val = 1
        matrix.set_item(0, 0, val)

        self.assertEquals(val, matrix.get_item(0, 0))
Ejemplo n.º 11
0
    def test_should_transpose_1x1_matrix(self):
        matrix = Matrix(1, 1, 1)

        matrix.transpose()

        self.assertEquals(1, matrix.get_item(0, 0))