本文整理汇总了Python中pycast.common.matrix.Matrix.set_value方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.set_value方法的具体用法?Python Matrix.set_value怎么用?Python Matrix.set_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycast.common.matrix.Matrix
的用法示例。
在下文中一共展示了Matrix.set_value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_value_test
# 需要导入模块: from pycast.common.matrix import Matrix [as 别名]
# 或者: from pycast.common.matrix.Matrix import set_value [as 别名]
def set_value_test(self):
"""Test if the new value is correctly set in the matrix."""
rows = 2
cols = 3
data = [
[1, 2, 3],
[4, 5, 6]
]
matrix = Matrix(cols, rows)
matrix.initialize(data, rowBased=True)
# Change value at specified column/row
matrix.set_value(1, 0, 10)
matrix.set_value(2, 1, 9)
# Test if the new value is set correctly
self.assertEqual(matrix.matrix[1][0], 10)
self.assertEqual(matrix.matrix[2][1], 9)
示例2: equality_test
# 需要导入模块: from pycast.common.matrix import Matrix [as 别名]
# 或者: from pycast.common.matrix.Matrix import set_value [as 别名]
def equality_test(self):
"""Test the == operator for Matrix instances."""
rows = 3
cols = 2
data = [
[1, 2, 3],
[4, 5, 6]
]
mtrx1 = Matrix(cols, rows)
mtrx2 = Matrix(cols, rows)
mtrx3 = Matrix(cols, rows)
mtrx1.initialize(data, rowBased=False)
mtrx2.initialize(data, rowBased=False)
mtrx3.initialize(data, rowBased=False)
# change value at one postion
mtrx2.set_value(1, 2, 4)
# same value as float -> Matrix should still be equal
mtrx3.set_value(0, 1, 2.0)
self.assertTrue(mtrx1 == mtrx3)
self.assertTrue(mtrx1 != mtrx2)
self.assertTrue(mtrx2 != mtrx3)
示例3: copy_test
# 需要导入模块: from pycast.common.matrix import Matrix [as 别名]
# 或者: from pycast.common.matrix.Matrix import set_value [as 别名]
def copy_test(self):
"""Test to clone the Matrix."""
# Initialize Test Objects
rows = 2
cols = 3
data = [
[1, 2, 3],
[4, 5, 6]
]
mtrx = Matrix(cols, rows)
mtrx.initialize(data, rowBased=True)
mtrx.optimizationEnabled = True
# Execute copy
cp = copy(mtrx)
# Test assertion
self.assertEqual(cp, mtrx)
# Changing values of mtrx should not affect cp
mtrx.set_value(2, 0, 10)
mtrx.optimizationEnabled = False
self.assertNotEqual(cp, mtrx)
self.assertNotEqual(mtrx.get_value(2, 0), cp.get_value(2, 0))
self.assertTrue(cp.optimizationEnabled)