本文整理汇总了Python中pycast.common.matrix.Matrix.get_value方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.get_value方法的具体用法?Python Matrix.get_value怎么用?Python Matrix.get_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycast.common.matrix.Matrix
的用法示例。
在下文中一共展示了Matrix.get_value方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: matrix_to_multi_dim_timeseries_test
# 需要导入模块: from pycast.common.matrix import Matrix [as 别名]
# 或者: from pycast.common.matrix.Matrix import get_value [as 别名]
def matrix_to_multi_dim_timeseries_test(self):
"""Test to create a Timeseries from a Matrix."""
rows = 5
cols = 3
data = [
[2.4, 4.5, 6.1],
[3.6, 3.2, 9.4],
[5.6, 3.2, 8.7],
[4.3, 7.1, 3.3],
[7.2, 9.6, 0.3]
]
mtrx = Matrix(cols, rows)
mtrx.initialize(data, True)
ts = mtrx.to_multi_dim_timeseries()
tsData = [
[0, [2.4, 4.5, 6.1]],
[1, [3.6, 3.2, 9.4]],
[2, [5.6, 3.2, 8.7]],
[3, [4.3, 7.1, 3.3]],
[4, [7.2, 9.6, 0.3]]
]
exTs = MDTS.from_twodim_list(tsData, dimensions=3)
# expecting that TimeSeries.from_twodom_list() works properly
self.assertEqual(ts, exTs)
# Changing entries of the timeseries, should not affect matrix
row = 3
ts[row] = [row, 4, 3, 1]
for col in xrange(cols):
self.assertEqual(mtrx.get_value(col, row), data[row][col])
示例2: get_array_test
# 需要导入模块: from pycast.common.matrix import Matrix [as 别名]
# 或者: from pycast.common.matrix.Matrix import get_value [as 别名]
def get_array_test(self):
"""Test if get_array method returns an array with the correct values."""
rows = 2
cols = 3
data = [
[1, 2, 3],
[4, 5, 6]
]
matrix = Matrix(cols, rows)
matrix.initialize(data, rowBased=True)
for row in xrange(rows):
for col in xrange(cols):
self.assertEqual(matrix.get_value(col, row), data[row][col])
示例3: get_value_test
# 需要导入模块: from pycast.common.matrix import Matrix [as 别名]
# 或者: from pycast.common.matrix.Matrix import get_value [as 别名]
def get_value_test(self):
"""Test if the correct value of the Matrix is returned."""
rows = 2
cols = 3
data = [
[1, 2, 3],
[4, 5, 6]
]
matrix = Matrix(cols, rows)
matrix.initialize(data, rowBased=True)
val1 = matrix.get_value(1, 0)
val2 = matrix.get_value(2, 1)
self.assertEqual(val1, 2)
self.assertEqual(val2, 6)
示例4: copy_test
# 需要导入模块: from pycast.common.matrix import Matrix [as 别名]
# 或者: from pycast.common.matrix.Matrix import get_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)