当前位置: 首页>>代码示例>>Python>>正文


Python Matrix.get方法代码示例

本文整理汇总了Python中matrix.Matrix.get方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.get方法的具体用法?Python Matrix.get怎么用?Python Matrix.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matrix.Matrix的用法示例。


在下文中一共展示了Matrix.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testMatrixConstructionWithInitialization

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import get [as 别名]
    def testMatrixConstructionWithInitialization(self):
        """Создание и инициализация матрицы"""

        # создаём матрицу и проверяем, что значения её элементов соответствуют тем,
        # при помощи которых была выполнена инициализация
        m = Matrix([[1, 2, 3], [4, 5, 6]])

        self.assertEqual(m.get(0, 0), 1)
        self.assertEqual(m.get(0, 1), 2)
        self.assertEqual(m.get(0, 2), 3)
        self.assertEqual(m.get(1, 0), 4)
        self.assertEqual(m.get(1, 1), 5)
        self.assertEqual(m.get(1, 2), 6)
开发者ID:PakhnovaMaria,项目名称:Pakhnova1sem,代码行数:15,代码来源:test.py

示例2: testMatrixSet

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import get [as 别名]
    def testMatrixSet(self):
        """Изменение значений матрицы"""

        # тестируем механизм изменения значений элементов матрицы
        m = Matrix(1, 2)

        m.set(0, 0, 1)
        m.set(0, 1, 2)

        self.assertEqual(m.get(0, 0), 1)
        self.assertEqual(m.get(0, 1), 2)
开发者ID:EfimRyabushev,项目名称:lab12,代码行数:13,代码来源:Tests.py

示例3: testMatrixConstructWithoutInitialization

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import get [as 别名]
    def testMatrixConstructWithoutInitialization(self):
        dims = [(2, 2), (3, 4), (4, 3)]

        for (m, n) in dims:
            a = Matrix(m, n)

            self.assertEqual(a.get_m(), m)
            self.assertEqual(a.get_n(), n)
            self.assertEqual(a.get_size(), (m, n))

            for i in range(m):
                for j in range(n):
                    self.assertEqual(a.get(i, j), 0)
开发者ID:PakhnovaMaria,项目名称:Pakhnova1sem,代码行数:15,代码来源:test.py

示例4: testMatrixConstructWithoutInitialization

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import get [as 别名]
    def testMatrixConstructWithoutInitialization(self):
        """Создание матрицы без инициализации"""

        # тестирум возможность создания матриц разных размеров
        # для каждой матрицы проверяем, что по-умолчанию она заполнена нулями
        dims = [(2, 2), (3, 4), (4, 3)]

        for (m, n) in dims:
            a = Matrix(m, n)

            self.assertEqual(a.get_m(), m)
            self.assertEqual(a.get_n(), n)
            self.assertEqual(a.get_size(), (m, n))

            for i in range(m):
                for j in range(n):
                    self.assertEqual(a.get(i, j), 0)
开发者ID:EfimRyabushev,项目名称:lab12,代码行数:19,代码来源:Tests.py

示例5: test_set_value

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import get [as 别名]
 def test_set_value(self):
     matrix = Matrix(8, 8)
     matrix.set(8, 8, 15)
     self.assertEquals(matrix.get(8, 8), 15)
开发者ID:rodrigoavalente,项目名称:EditorGrafico,代码行数:6,代码来源:matrix_test.py

示例6: test_wrong_type_column

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import get [as 别名]
 def test_wrong_type_column(self):
     matrix = Matrix(5, 5)
     value = matrix.get(0, 1.5)
     value = matrix.get(0, "1")
     self.assertRaises(ValueError)
开发者ID:rodrigoavalente,项目名称:EditorGrafico,代码行数:7,代码来源:matrix_test.py

示例7: test_get_value

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import get [as 别名]
 def test_get_value(self):
     matrix = Matrix(7, 8)
     value = matrix.get(1, 6)
     self.assertEqual(value, 0)
开发者ID:rodrigoavalente,项目名称:EditorGrafico,代码行数:6,代码来源:matrix_test.py

示例8: test_negative_column

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import get [as 别名]
 def test_negative_column(self):
     matrix = Matrix(5, 5)
     value = matrix.get(0, -1)
     self.assertRaises(IndexError)
开发者ID:rodrigoavalente,项目名称:EditorGrafico,代码行数:6,代码来源:matrix_test.py

示例9: test_column_out_of_range

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import get [as 别名]
 def test_column_out_of_range(self):
     matrix = Matrix(5, 5)
     value = matrix.get(0, 5)
     self.assertRaises(IndexError)
开发者ID:rodrigoavalente,项目名称:EditorGrafico,代码行数:6,代码来源:matrix_test.py

示例10: test_wrong_type_row

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import get [as 别名]
 def test_wrong_type_row(self):
     matrix = Matrix(2, 3)
     value = matrix.get(1.5, 2)
     value = matrix.get("1", 2)
     self.assertRaises(TypeError)
开发者ID:rodrigoavalente,项目名称:EditorGrafico,代码行数:7,代码来源:matrix_test.py

示例11: test_negative_row

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import get [as 别名]
 def test_negative_row(self):
     matrix = Matrix(5, 5)
     value = matrix.get(-1, 0)
     self.assertRaises(IndexError)
开发者ID:rodrigoavalente,项目名称:EditorGrafico,代码行数:6,代码来源:matrix_test.py

示例12: test_row_out_of_range

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import get [as 别名]
 def test_row_out_of_range(self):
     matrix = Matrix(5, 5)
     value = matrix.get(5, 0)
     self.assertRaises(IndexError)
开发者ID:rodrigoavalente,项目名称:EditorGrafico,代码行数:6,代码来源:matrix_test.py


注:本文中的matrix.Matrix.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。