本文整理汇总了Python中ert.util.DoubleVector类的典型用法代码示例。如果您正苦于以下问题:Python DoubleVector类的具体用法?Python DoubleVector怎么用?Python DoubleVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DoubleVector类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_vector_operations_with_exceptions
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
示例2: loadVector
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)
示例3: test_element_sum
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
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
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
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
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_plot_block_data
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])
示例9: blockedProduction
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")
示例10: test_double_vector
def test_double_vector(self):
v = DoubleVector()
v[0] = 77.25
v[1] = 123.25
v[2] = 66.25
v[3] = 56.25
v[4] = 111.25
v[5] = 99.25
v[12] = 12
self.assertEqual(len(v), 13)
self.assertEqual(list(v), [v[0], v[1], v[2], v[3], v[4], v[5], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v[12]])
v.clear()
self.assertEqual(len(v), 0)
v.clear()
v[0] = 0.1
v[1] = 0.2
v[2] = 0.4
v[3] = 0.8
v2 = v * 2
self.assertEqual(list(v2), [v[0] * 2, v[1] * 2, v[2] * 2, v[3] * 2])
v2 += v
self.assertEqual(list(v2), [v[0] * 3, v[1] * 3, v[2] * 3, v[3] * 3])
v2.assign(0.66)
self.assertEqual(list(v2), [0.66, 0.66, 0.66, 0.66])
v.assign(v2)
self.assertEqual(list(v), [0.66, 0.66, 0.66, 0.66])
v.clear()
v.default = 0.75
self.assertEqual(v.default, 0.75)
v[2] = 0.0
self.assertEqual(v[1], 0.75)
示例11: test_polyfit
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])
示例12: center
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 )
示例13: test_permutation_vector
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)