本文整理汇总了Python中ert.util.DoubleVector.append方法的典型用法代码示例。如果您正苦于以下问题:Python DoubleVector.append方法的具体用法?Python DoubleVector.append怎么用?Python DoubleVector.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ert.util.DoubleVector
的用法示例。
在下文中一共展示了DoubleVector.append方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadVector
# 需要导入模块: from ert.util import DoubleVector [as 别名]
# 或者: from ert.util.DoubleVector import append [as 别名]
def loadVector(self, plot_block_data, fs, report_step, realization_number):
"""
@type plot_block_data: PlotBlockData
@type fs: EnkfFs
@type report_step: int
@type realization_number: int
@rtype PlotBlockVector
"""
config_node = self.__obs_vector.getConfigNode()
is_private_container = config_node.getImplementationType() == ErtImplType.CONTAINER
data_node = EnkfNode(config_node, private=is_private_container)
node_id = NodeId(report_step, realization_number)
if data_node.tryLoad(fs, node_id):
block_obs = self.getBlockObservation(report_step)
data = DoubleVector()
for index in range(len(block_obs)):
value = block_obs.getData(data_node.valuePointer(), index, node_id)
data.append(value)
data.permute(self.__permutation_vector)
plot_block_vector = PlotBlockVector(realization_number, data)
plot_block_data.addPlotBlockVector(plot_block_vector)
示例2: test_vector_operations_with_exceptions
# 需要导入模块: from ert.util import DoubleVector [as 别名]
# 或者: from ert.util.DoubleVector import append [as 别名]
def test_vector_operations_with_exceptions(self):
iv1 = IntVector()
iv1.append(1)
iv1.append(2)
iv1.append(3)
iv2 = IntVector()
iv2.append(4)
iv2.append(5)
dv1 = DoubleVector()
dv1.append(0.5)
dv1.append(0.75)
dv1.append(0.25)
#Size mismatch
with self.assertRaises(ValueError):
iv3 = iv1 + iv2
#Size mismatch
with self.assertRaises(ValueError):
iv3 = iv1 * iv2
#Type mismatch
with self.assertRaises(TypeError):
iv1 += dv1
#Type mismatch
with self.assertRaises(TypeError):
iv1 *= dv1
示例3: test_element_sum
# 需要导入模块: from ert.util import DoubleVector [as 别名]
# 或者: from ert.util.DoubleVector import append [as 别名]
def test_element_sum(self):
dv = DoubleVector()
iv = IntVector()
for i in range(10):
dv.append(i+1)
iv.append(i+1)
self.assertEqual( dv.elementSum() , 55 )
self.assertEqual( iv.elementSum() , 55 )
示例4: test_stat_quantiles
# 需要导入模块: from ert.util import DoubleVector [as 别名]
# 或者: from ert.util.DoubleVector import append [as 别名]
def test_stat_quantiles(self):
v = DoubleVector()
for i in range(100000):
v.append(random.random())
self.assertAlmostEqual(quantile(v, 0.1), 0.1, 2)
self.assertAlmostEqual(quantile_sorted(v, 0.2), 0.2, 2)
self.assertAlmostEqual(quantile_sorted(v, 0.3), 0.3, 2)
self.assertAlmostEqual(quantile_sorted(v, 0.4), 0.4, 2)
self.assertAlmostEqual(quantile_sorted(v, 0.5), 0.5, 2)
示例5: getDepthValues
# 需要导入模块: from ert.util import DoubleVector [as 别名]
# 或者: from ert.util.DoubleVector import append [as 别名]
def getDepthValues(self, report_step):
""" @rtype: DoubleVector """
block_obs = self.getBlockObservation(report_step)
depth = DoubleVector()
for index in block_obs:
value = block_obs.getDepth(index)
depth.append(value)
return depth
示例6: test_plot_block_vector
# 需要导入模块: from ert.util import DoubleVector [as 别名]
# 或者: from ert.util.DoubleVector import append [as 别名]
def test_plot_block_vector(self):
vector = DoubleVector()
vector.append(1.5)
vector.append(2.5)
vector.append(3.5)
plot_block_vector = PlotBlockVector(1, vector)
self.assertEqual(plot_block_vector.getRealizationNumber(), 1)
self.assertEqual(plot_block_vector[0], 1.5)
self.assertEqual(plot_block_vector[2], 3.5)
self.assertEqual(len(plot_block_vector), len(vector))
示例7: test_stat_quantiles
# 需要导入模块: from ert.util import DoubleVector [as 别名]
# 或者: from ert.util.DoubleVector import append [as 别名]
def test_stat_quantiles(self):
rng = RandomNumberGenerator()
rng.setState("0123456789ABCDEF")
v = DoubleVector()
for i in range(100000):
v.append(rng.getDouble( ))
self.assertAlmostEqual(quantile(v, 0.1), 0.1, 2)
self.assertAlmostEqual(quantile_sorted(v, 0.2), 0.2, 2)
self.assertAlmostEqual(quantile_sorted(v, 0.3), 0.3, 2)
self.assertAlmostEqual(quantile_sorted(v, 0.4), 0.4, 2)
self.assertAlmostEqual(quantile_sorted(v, 0.5), 0.5, 2)
示例8: test_permutation_vector
# 需要导入模块: from ert.util import DoubleVector [as 别名]
# 或者: from ert.util.DoubleVector import append [as 别名]
def test_permutation_vector(self):
vector = DoubleVector()
for i in range(5, 0, -1):
vector.append(i)
permutation_vector = vector.permutationSort()
for index, value in enumerate(range(5, 0, -1)):
self.assertEqual(vector[index], value)
vector.permute(permutation_vector)
for index, value in enumerate(range(1, 6)):
self.assertEqual(vector[index], value)
示例9: test_plot_block_data
# 需要导入模块: from ert.util import DoubleVector [as 别名]
# 或者: from ert.util.DoubleVector import append [as 别名]
def test_plot_block_data(self):
depth = DoubleVector()
depth.append(2.5)
depth.append(3.5)
data = PlotBlockData(depth)
self.assertEqual(data.getDepth(), depth)
vector = PlotBlockVector(1, DoubleVector())
data.addPlotBlockVector(vector)
data.addPlotBlockVector(PlotBlockVector(2, DoubleVector()))
self.assertEqual(len(data), 2)
self.assertEqual(vector, data[1])
示例10: center
# 需要导入模块: from ert.util import DoubleVector [as 别名]
# 或者: from ert.util.DoubleVector import append [as 别名]
def center(self):
xlist = DoubleVector( )
ylist = DoubleVector( )
for segment in self:
C1 = segment.getC1()
C2 = segment.getC2()
(J1 , I1) = divmod(C1 , self.__grid.getNX() + 1)
(J2 , I2) = divmod(C2 , self.__grid.getNX() + 1)
(x1,y1,z) = self.__grid.getNodePos( I1 , J1 , self.__k )
(x2,y2,z) = self.__grid.getNodePos( I2 , J2 , self.__k )
xlist.append( x1 )
xlist.append( x2 )
ylist.append( y1 )
ylist.append( y2 )
N = len(xlist)
return (xlist.elementSum()/N , ylist.elementSum()/N )
示例11: blockedProduction
# 需要导入模块: from ert.util import DoubleVector [as 别名]
# 或者: from ert.util.DoubleVector import append [as 别名]
def blockedProduction(self , totalKey , timeRange):
node = self.smspec_node(totalKey)
if node.is_total:
total = DoubleVector()
for t in timeRange:
if t < CTime(self.start_time):
total.append( 0 )
elif t >= CTime( self.end_time):
total.append( self.get_last_value( totalKey ))
else:
total.append( self.get_interp( totalKey , date = t ))
tmp = total << 1
total.pop()
return tmp - total
else:
raise TypeError("The blockedProduction method must be called with one of the TOTAL keys like e.g. FOPT or GWIT")
示例12: test_polyfit
# 需要导入模块: from ert.util import DoubleVector [as 别名]
# 或者: from ert.util.DoubleVector import append [as 别名]
def test_polyfit(self):
x_list = DoubleVector()
y_list = DoubleVector()
S = DoubleVector()
A = 7.25
B = -4
C = 0.025
x = 0
dx = 0.1
for i in range(100):
y = A + B * x + C * x * x
x_list.append(x)
y_list.append(y)
x += dx
S.append(1.0)
beta = polyfit(3, x_list, y_list, None)
self.assertAlmostEqual(A, beta[0])
self.assertAlmostEqual(B, beta[1])
self.assertAlmostEqual(C, beta[2])