本文整理汇总了Python中ert.ecl.EclFile.blockView方法的典型用法代码示例。如果您正苦于以下问题:Python EclFile.blockView方法的具体用法?Python EclFile.blockView怎么用?Python EclFile.blockView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ert.ecl.EclFile
的用法示例。
在下文中一共展示了EclFile.blockView方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_block_view
# 需要导入模块: from ert.ecl import EclFile [as 别名]
# 或者: from ert.ecl.EclFile import blockView [as 别名]
def test_block_view(self):
with TestAreaContext("python/ecl_file/view"):
with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f:
for i in range(5):
header = EclKW("HEADER" , 1 , EclTypeEnum.ECL_INT_TYPE )
header[0] = i
data1 = EclKW("DATA1" , 100 , EclTypeEnum.ECL_INT_TYPE )
data1.assign( i )
data2 = EclKW("DATA2" , 100 , EclTypeEnum.ECL_INT_TYPE )
data2.assign( i*10 )
header.fwrite( f )
data1.fwrite( f )
data2.fwrite( f )
ecl_file = EclFile("TEST")
with self.assertRaises(KeyError):
ecl_file.blockView("NO" , 1)
with self.assertRaises(IndexError):
ecl_file.blockView("HEADER" , 100)
for i in range(5):
view = ecl_file.blockView("HEADER" , i)
self.assertEqual( len(view) , 3)
header = view["HEADER"][0]
data1 = view["DATA1"][0]
data2 = view["DATA2"][0]
self.assertEqual( header[0] , i )
self.assertEqual( data1[99] , i )
self.assertEqual( data2[99] , i*10 )
for i in range(5):
view = ecl_file.blockView2("HEADER" , "DATA2", i )
self.assertEqual( len(view) , 2)
header = view["HEADER"][0]
data1 = view["DATA1"][0]
self.assertEqual( header[0] , i )
self.assertEqual( data1[99] , i )
self.assertFalse( "DATA2" in view )
view = ecl_file.blockView2("HEADER" , None, 0 )
self.assertEqual( len(view) , len(ecl_file))
view = ecl_file.blockView2(None , "DATA2", 0 )