本文整理汇总了Python中ert.util.IntVector.append方法的典型用法代码示例。如果您正苦于以下问题:Python IntVector.append方法的具体用法?Python IntVector.append怎么用?Python IntVector.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ert.util.IntVector
的用法示例。
在下文中一共展示了IntVector.append方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_element_sum
# 需要导入模块: from ert.util import IntVector [as 别名]
# 或者: from ert.util.IntVector 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 )
示例2: report_index_list
# 需要导入模块: from ert.util import IntVector [as 别名]
# 或者: from ert.util.IntVector import append [as 别名]
def report_index_list( self ):
"""
Internal function for working with report_steps.
"""
first_report = self.first_report
last_report = self.last_report
index_list = IntVector()
for report_step in range( first_report , last_report + 1):
time_index = EclSum.cNamespace().get_report_end( self , report_step )
index_list.append( time_index )
return index_list
示例3: test_pop
# 需要导入模块: from ert.util import IntVector [as 别名]
# 或者: from ert.util.IntVector import append [as 别名]
def test_pop(self):
a = IntVector()
a.append(1)
a.append(2)
self.assertEqual( a.pop() , 2 )
self.assertEqual( len(a) , 1 )
self.assertEqual( a.pop() , 1 )
self.assertEqual( len(a) , 0 )
with self.assertRaises(ValueError):
a.pop()
示例4: test_unique
# 需要导入模块: from ert.util import IntVector [as 别名]
# 或者: from ert.util.IntVector import append [as 别名]
def test_unique(self):
iv = IntVector()
iv.append(1)
iv.append(1)
iv.append(1)
iv.append(0)
iv.append(1)
iv.append(2)
iv.append(2)
iv.append(0)
iv.append(3)
iv.selectUnique()
self.assertEqual( len(iv) , 4)
self.assertEqual( iv[0] , 0 )
self.assertEqual( iv[1] , 1 )
self.assertEqual( iv[2] , 2 )
self.assertEqual( iv[3] , 3 )
示例5: test_field_export_many
# 需要导入模块: from ert.util import IntVector [as 别名]
# 或者: from ert.util.IntVector import append [as 别名]
def test_field_export_many(self):
with ErtTestContext("export_test", self.config_file) as test_context:
ert = test_context.getErt()
fs_manager = ert.getEnkfFsManager( )
ens_config = ert.ensembleConfig()
config_node = ens_config["PERMX"]
iens_list = IntVector( )
iens_list.append(0)
iens_list.append(2)
iens_list.append(4)
fs = fs_manager.getCurrentFileSystem( )
# Filename without embedded %d - TypeError
with self.assertRaises(TypeError):
EnkfNode.exportMany( config_node , "export/with/path/PERMX.grdecl" , fs , iens_list )
EnkfNode.exportMany( config_node , "export/with/path/PERMX_%d.grdecl" , fs , iens_list )
self.assertTrue( os.path.isfile("export/with/path/PERMX_0.grdecl") )
self.assertTrue( os.path.isfile("export/with/path/PERMX_2.grdecl") )
self.assertTrue( os.path.isfile("export/with/path/PERMX_4.grdecl") )
示例6: test_vector_operations_with_exceptions
# 需要导入模块: from ert.util import IntVector [as 别名]
# 或者: from ert.util.IntVector 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
示例7: test_shift
# 需要导入模块: from ert.util import IntVector [as 别名]
# 或者: from ert.util.IntVector import append [as 别名]
def test_shift(self):
a = IntVector()
a.append(1)
a.append(2)
a.append(3)
a.append(4)
a.append(5)
with self.assertRaises(ValueError):
a >> -1
with self.assertRaises(ValueError):
a << -1
with self.assertRaises(ValueError):
a << -6
b = a << 2
self.assertEqual(list(b) , [3,4,5])
print a
a <<= 2
print a
self.assertEqual(list(a) , [3,4,5])
b = a >> 2
self.assertEqual(list(b) , [0,0,3,4,5])
a >>= 2
self.assertEqual(list(a) , [0,0,3,4,5])
示例8: test_int_vector
# 需要导入模块: from ert.util import IntVector [as 别名]
# 或者: from ert.util.IntVector import append [as 别名]
def test_int_vector(self):
a = IntVector()
a.append(1)
a.append(2)
a.append(3)
a.append(4)
a.append(5)
self.assertEqual(list(a), [1, 2, 3, 4, 5])
a.sort(reverse=True)
self.assertEqual(list(a), [5, 4, 3, 2, 1])
self.assertTrue(a.max, 5)
self.assertTrue(a.min, 1)
self.assertTrue(a.minIndex(), 4)
self.assertEqual(a.maxIndex(reverse=True), 0)
self.assertEqual(a.maxIndex(reverse=False), 0)
a[4] = 5
self.assertTrue(a[4] == 5)
a_plus_one = a + 1
self.assertEqual(list(a_plus_one), [6, 5, 4, 3, 6])
sliced = a[0:3]
self.assertEqual(list(sliced), [5, 4, 3])
with self.assertRaises(IndexError):
item = a[6]
copy_of_a = copy.deepcopy(a)
self.assertEqual(list(a), list(copy_of_a))
another_copy_of_a = copy.copy(a)
self.assertEqual(list(a), list(another_copy_of_a))
示例9: test_ecl_file_indexed_read
# 需要导入模块: from ert.util import IntVector [as 别名]
# 或者: from ert.util.IntVector import append [as 别名]
def test_ecl_file_indexed_read(self):
with TestAreaContext("ecl_file_indexed_read") as area:
fortio = FortIO("ecl_file_index_test", mode=FortIO.WRITE_MODE)
element_count = 100000
ecl_kw_1 = EclKW("TEST1", element_count, EclDataType.ECL_INT)
ecl_kw_2 = EclKW("TEST2", element_count, EclDataType.ECL_INT)
for index in range(element_count):
ecl_kw_1[index] = index
ecl_kw_2[index] = index + 3
ecl_kw_1.fwrite(fortio)
ecl_kw_2.fwrite(fortio)
fortio.close()
ecl_file = EclFile("ecl_file_index_test")
index_map = IntVector()
index_map.append(2)
index_map.append(3)
index_map.append(5)
index_map.append(7)
index_map.append(11)
index_map.append(13)
index_map.append(313)
index_map.append(1867)
index_map.append(5227)
index_map.append(7159)
index_map.append(12689)
index_map.append(18719)
index_map.append(32321)
index_map.append(37879)
index_map.append(54167)
index_map.append(77213)
index_map.append(88843)
index_map.append(99991)
char_buffer_1 = ctypes.create_string_buffer(len(index_map) * ctypes.sizeof(ctypes.c_int))
char_buffer_2 = ctypes.create_string_buffer(len(index_map) * ctypes.sizeof(ctypes.c_int))
self._eclFileIndexedRead(ecl_file, "TEST2", 0, index_map, char_buffer_2)
self._eclFileIndexedRead(ecl_file, "TEST1", 0, index_map, char_buffer_1)
int_buffer_1 = ctypes.cast(char_buffer_1, ctypes.POINTER(ctypes.c_int))
int_buffer_2 = ctypes.cast(char_buffer_2, ctypes.POINTER(ctypes.c_int))
for index, index_map_value in enumerate(index_map):
self.assertEqual(index_map_value, int_buffer_1[index])
self.assertEqual(index_map_value, int_buffer_2[index] - 3)
示例10: test_ecl_kw_indexed_read
# 需要导入模块: from ert.util import IntVector [as 别名]
# 或者: from ert.util.IntVector import append [as 别名]
def test_ecl_kw_indexed_read(self):
with TestAreaContext("ecl_kw_indexed_read") as area:
fortio = FortIO("index_test", mode=FortIO.WRITE_MODE)
element_count = 100000
ecl_kw = EclKW("TEST", element_count, EclDataType.ECL_INT)
for index in range(element_count):
ecl_kw[index] = index
ecl_kw.fwrite(fortio)
fortio.close()
fortio = FortIO("index_test", mode=FortIO.READ_MODE)
new_ecl_kw = EclKW.fread(fortio)
for index in range(element_count):
self.assertEqual(new_ecl_kw[index], index)
index_map = IntVector()
index_map.append(2)
index_map.append(3)
index_map.append(5)
index_map.append(7)
index_map.append(11)
index_map.append(13)
index_map.append(313)
index_map.append(1867)
index_map.append(5227)
index_map.append(7159)
index_map.append(12689)
index_map.append(18719)
index_map.append(32321)
index_map.append(37879)
index_map.append(54167)
index_map.append(77213)
index_map.append(88843)
index_map.append(99991)
char_buffer = ctypes.create_string_buffer(len(index_map) * ctypes.sizeof(ctypes.c_int))
self._freadIndexedData(fortio, 24, EclDataType.ECL_INT, element_count, index_map, char_buffer)
int_buffer = ctypes.cast(char_buffer, ctypes.POINTER(ctypes.c_int))
for index, index_map_value in enumerate(index_map):
self.assertEqual(index_map_value, int_buffer[index])