예제 #1
0
    def test_fortio_read_and_write_and_rewrite(self):
        with TestAreaContext("python/fortio/read_and_write_and_rewrite"):
            record_size = 4000

            f = FortIO("complete", FortIO.WRITE_MODE)
            for c in "abcdefghijklmnopqrstuvwxyz":
                data = bytearray(c * record_size)
                f.writeRecord(data)


            f = FortIO("test", FortIO.WRITE_MODE)

            positions = {}
            for c in "abcdefghij-lmnopqrstuvwxyz":
                data = bytearray(c * record_size)
                f.writeRecord(data)
                positions[c] = f.getPosition()


            f = FortIO("test", FortIO.READ_AND_WRITE_MODE)

            f.seek(positions["j"])

            new_data = bytearray("k" * record_size)
            f.writeRecord(new_data)

            f.close()

            self.assertFilesAreEqual("test", "complete")
예제 #2
0
    def test_fortio_read_and_write_and_rewrite(self):
        with TestAreaContext("python/fortio/read_and_write_and_rewrite"):
            record_size = 4000

            f = FortIO("complete", FortIO.WRITE_MODE)
            for c in "abcdefghijklmnopqrstuvwxyz":
                data = bytearray(c * record_size)
                f.writeRecord(data)


            f = FortIO("test", FortIO.WRITE_MODE)

            positions = {}
            for c in "abcdefghij-lmnopqrstuvwxyz":
                data = bytearray(c * record_size)
                f.writeRecord(data)
                positions[c] = f.getPosition()


            f = FortIO("test", FortIO.READ_AND_WRITE_MODE)

            f.seek(positions["j"])

            new_data = bytearray("k" * record_size)
            f.writeRecord(new_data)

            f.close()

            self.assertFilesAreEqual("test", "complete")
예제 #3
0
    def test_kw_write(self):
        with TestAreaContext("python/ecl_kw/writing"):

            data = [random.random() for i in range(10000)]

            kw = EclKW("TEST", len(data), EclTypeEnum.ECL_DOUBLE_TYPE)
            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))
예제 #4
0
파일: test_ecl_kw.py 프로젝트: flikka/ert
    def test_kw_write(self):
        with TestAreaContext("python/ecl_kw/writing"):

            data = [random.random() for i in range(10000)]

            kw = EclKW("TEST", len(data), EclTypeEnum.ECL_DOUBLE_TYPE)
            i = 0
            for d in data:
                kw[i] = d
                i += 1

            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))