本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)