本文整理汇总了Python中ecl.eclfile.EclKW.equal方法的典型用法代码示例。如果您正苦于以下问题:Python EclKW.equal方法的具体用法?Python EclKW.equal怎么用?Python EclKW.equal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ecl.eclfile.EclKW
的用法示例。
在下文中一共展示了EclKW.equal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_kw
# 需要导入模块: from ecl.eclfile import EclKW [as 别名]
# 或者: from ecl.eclfile.EclKW import equal [as 别名]
def test_save_kw(self):
with TestAreaContext("python/ecl_file/save_kw"):
data = range(1000)
kw = EclKW("MY_KEY", len(data), EclDataType.ECL_INT)
for index, val in enumerate(data):
kw[index] = val
clean_dump = "my_clean_file"
fortio = FortIO(clean_dump, FortIO.WRITE_MODE)
kw.fwrite(fortio)
fortio.close()
test_file = "my_dump_file"
fortio = FortIO(test_file, FortIO.WRITE_MODE)
kw.fwrite(fortio)
fortio.close()
self.assertFilesAreEqual(clean_dump, test_file)
ecl_file = EclFile(test_file, flags=EclFileFlagEnum.ECL_FILE_WRITABLE)
loaded_kw = ecl_file["MY_KEY"][0]
self.assertTrue(kw.equal(loaded_kw))
ecl_file.save_kw(loaded_kw)
ecl_file.close()
self.assertFilesAreEqual(clean_dump, test_file)
ecl_file = EclFile(test_file)
loaded_kw = ecl_file["MY_KEY"][0]
self.assertTrue(kw.equal(loaded_kw))
示例2: test_kw_write
# 需要导入模块: from ecl.eclfile import EclKW [as 别名]
# 或者: from ecl.eclfile.EclKW import equal [as 别名]
def test_kw_write(self):
with TestAreaContext("python/ecl_kw/writing"):
data = [random.random() for i in range(10000)]
kw = EclKW("TEST", len(data), EclDataType.ECL_DOUBLE)
i = 0
for d in data:
kw[i] = d
i += 1
pfx = 'EclKW('
self.assertEqual(pfx, repr(kw)[:len(pfx)])
fortio = FortIO("ECL_KW_TEST", FortIO.WRITE_MODE)
kw.fwrite(fortio)
fortio.close()
fortio = FortIO("ECL_KW_TEST")
kw2 = EclKW.fread(fortio)
self.assertTrue(kw.equal(kw2))
ecl_file = EclFile("ECL_KW_TEST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE)
kw3 = ecl_file["TEST"][0]
self.assertTrue(kw.equal(kw3))
ecl_file.save_kw(kw3)
ecl_file.close()
fortio = FortIO("ECL_KW_TEST", FortIO.READ_AND_WRITE_MODE)
kw4 = EclKW.fread(fortio)
self.assertTrue(kw.equal(kw4))
fortio.seek(0)
kw4.fwrite(fortio)
fortio.close()
ecl_file = EclFile("ECL_KW_TEST")
kw5 = ecl_file["TEST"][0]
self.assertTrue(kw.equal(kw5))
示例3: test_equal
# 需要导入模块: from ecl.eclfile import EclKW [as 别名]
# 或者: from ecl.eclfile.EclKW import equal [as 别名]
def test_equal(self):
kw1 = EclKW("TEST", 3, EclDataType.ECL_CHAR)
kw1[0] = "Test1"
kw1[1] = "Test13"
kw1[2] = "Test15"
kw2 = EclKW("TEST", 3, EclDataType.ECL_CHAR)
kw2[0] = "Test1"
kw2[1] = "Test13"
kw2[2] = "Test15"
self.assertTrue(kw1.equal(kw2))
self.assertTrue(kw1.equal_numeric(kw2))
kw2[2] = "Test15X"
self.assertFalse(kw1.equal(kw2))
self.assertFalse(kw1.equal_numeric(kw2))
unrst_file_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST")
unrst_file = EclFile(unrst_file_path)
kw1 = unrst_file["PRESSURE"][0]
kw2 = kw1.deep_copy()
self.assertTrue(kw1.equal(kw2))
self.assertTrue(kw1.equal_numeric(kw2))
kw2 *= 1.00001
self.assertFalse(kw1.equal(kw2))
self.assertFalse(kw1.equal_numeric(kw2, epsilon=1e-8))
self.assertTrue(kw1.equal_numeric(kw2, epsilon=1e-2))
kw1 = unrst_file["ICON"][10]
kw2 = kw1.deep_copy()
self.assertTrue(kw1.equal(kw2))
self.assertTrue(kw1.equal_numeric(kw2))
kw1[-1] += 1
self.assertFalse(kw1.equal(kw2))
self.assertFalse(kw1.equal_numeric(kw2))