From 8e8abee55620aca11ca1733f1a0f02f9aeef2de5 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 23 Aug 2019 10:25:54 +0200 Subject: [PATCH] Renamed opm.parser -> opm.io --- python/python/opm/{parser => io}/__init__.py | 0 python/python/opm/{parser => io}/config.py | 0 .../opm/{parser => io}/deck/__init__.py | 0 python/python/opm/{parser => io}/parser.py | 0 .../python/opm/{parser => io}/properties.py | 0 python/python/opm/{parser => io}/schedule.py | 0 python/python/opm/{parser => io}/sunbeam.py | 0 python/setup.py | 2 +- python/tests/test_connection.py | 8 +++---- python/tests/test_deck.py | 2 +- python/tests/test_group_tree.py | 6 ++--- python/tests/test_grupnet.py | 4 ++-- python/tests/test_parse.py | 22 +++++++++---------- python/tests/test_parse_deck.py | 12 +++++----- python/tests/test_props.py | 4 ++-- python/tests/test_schedule.py | 8 +++---- python/tests/test_state.py | 12 +++++----- python/tests/test_time_vector.py | 2 +- python/tests/test_wells.py | 20 ++++++++--------- 19 files changed, 51 insertions(+), 51 deletions(-) rename python/python/opm/{parser => io}/__init__.py (100%) rename python/python/opm/{parser => io}/config.py (100%) rename python/python/opm/{parser => io}/deck/__init__.py (100%) rename python/python/opm/{parser => io}/parser.py (100%) rename python/python/opm/{parser => io}/properties.py (100%) rename python/python/opm/{parser => io}/schedule.py (100%) rename python/python/opm/{parser => io}/sunbeam.py (100%) diff --git a/python/python/opm/parser/__init__.py b/python/python/opm/io/__init__.py similarity index 100% rename from python/python/opm/parser/__init__.py rename to python/python/opm/io/__init__.py diff --git a/python/python/opm/parser/config.py b/python/python/opm/io/config.py similarity index 100% rename from python/python/opm/parser/config.py rename to python/python/opm/io/config.py diff --git a/python/python/opm/parser/deck/__init__.py b/python/python/opm/io/deck/__init__.py similarity index 100% rename from python/python/opm/parser/deck/__init__.py rename to python/python/opm/io/deck/__init__.py diff --git a/python/python/opm/parser/parser.py b/python/python/opm/io/parser.py similarity index 100% rename from python/python/opm/parser/parser.py rename to python/python/opm/io/parser.py diff --git a/python/python/opm/parser/properties.py b/python/python/opm/io/properties.py similarity index 100% rename from python/python/opm/parser/properties.py rename to python/python/opm/io/properties.py diff --git a/python/python/opm/parser/schedule.py b/python/python/opm/io/schedule.py similarity index 100% rename from python/python/opm/parser/schedule.py rename to python/python/opm/io/schedule.py diff --git a/python/python/opm/parser/sunbeam.py b/python/python/opm/io/sunbeam.py similarity index 100% rename from python/python/opm/parser/sunbeam.py rename to python/python/opm/io/sunbeam.py diff --git a/python/setup.py b/python/setup.py index 815c06887..c9b9c6ac4 100644 --- a/python/setup.py +++ b/python/setup.py @@ -75,7 +75,7 @@ setup( package_dir = {'': 'python'}, packages=[ 'opm', - 'opm.parser', + 'opm.io', 'opm.tools' ], ext_modules=ext_modules, diff --git a/python/tests/test_connection.py b/python/tests/test_connection.py index 30c47dd6d..536cad932 100644 --- a/python/tests/test_connection.py +++ b/python/tests/test_connection.py @@ -1,11 +1,11 @@ import unittest -import opm.parser +import opm.io class TestWells(unittest.TestCase): @classmethod def setUpClass(cls): - cls.sch = opm.parser.parse('tests/spe3/SPE3CASE1.DATA').schedule + cls.sch = opm.io.parse('tests/spe3/SPE3CASE1.DATA').schedule cls.timesteps = cls.sch.timesteps def test_connection_pos(self): @@ -26,8 +26,8 @@ class TestWells(unittest.TestCase): self.assertEqual("OPEN", connection.state) def test_filters(self): - flowing = opm.parser.schedule.Connection.flowing() - closed = opm.parser.schedule.Connection.closed() + flowing = opm.io.schedule.Connection.flowing() + closed = opm.io.schedule.Connection.closed() connections = self.sch.get_wells(0)[0].connections() self.assertEqual(len(list(filter(flowing, connections))), 2) self.assertEqual(len(list(filter(closed, connections))), 0) diff --git a/python/tests/test_deck.py b/python/tests/test_deck.py index 062be4f0e..9904dcf8d 100644 --- a/python/tests/test_deck.py +++ b/python/tests/test_deck.py @@ -1,5 +1,5 @@ import unittest -from opm.parser import load_deck_string +from opm.io import load_deck_string class TestParse(unittest.TestCase): diff --git a/python/tests/test_group_tree.py b/python/tests/test_group_tree.py index 975141299..3b97269fd 100644 --- a/python/tests/test_group_tree.py +++ b/python/tests/test_group_tree.py @@ -1,12 +1,12 @@ import sys import unittest -import opm.parser +import opm.io class TestGroupTree(unittest.TestCase): def setUp(self): norne = 'examples/data/norne/NORNE_ATW2013.DATA' - self.sch = opm.parser.parse(norne, [('PARSE_RANDOM_SLASH', opm.parser.action.ignore)]).schedule + self.sch = opm.io.parse(norne, [('PARSE_RANDOM_SLASH', opm.io.action.ignore)]).schedule def test_group(self): gr = self.sch.group(timestep=2)['PROD'] @@ -35,7 +35,7 @@ class TestGroupTree(unittest.TestCase): group = self.sch.group(timestep=3)['PROD'] children = ['MANI-B1', 'MANI-B2', 'MANI-D1', 'MANI-D2', 'MANI-E1', 'MANI-E2'] names = [child.name for child in group.children] - self.assertEqual(opm.parser.schedule.Group, type(child)) + self.assertEqual(opm.io.schedule.Group, type(child)) self.assertEqual(set(children), set(names)) if __name__ == '__main__': diff --git a/python/tests/test_grupnet.py b/python/tests/test_grupnet.py index ca8184299..64f2b421a 100644 --- a/python/tests/test_grupnet.py +++ b/python/tests/test_grupnet.py @@ -1,13 +1,13 @@ import sys import unittest -import opm.parser +import opm.io class TestGrupnet(unittest.TestCase): @classmethod def setUpClass(cls): norne = 'examples/data/norne/NORNE_ATW2013.DATA' - cls.sch = opm.parser.parse(norne, [('PARSE_RANDOM_SLASH', opm.parser.action.ignore)]).schedule + cls.sch = opm.io.parse(norne, [('PARSE_RANDOM_SLASH', opm.io.action.ignore)]).schedule def test_vfp_table(self): self.assertEqual(0, self.sch.group(timestep=0)['PROD'].vfp_table_nr) diff --git a/python/tests/test_parse.py b/python/tests/test_parse.py index 98f56e02e..fb46a5a5c 100644 --- a/python/tests/test_parse.py +++ b/python/tests/test_parse.py @@ -1,5 +1,5 @@ import unittest -import opm.parser +import opm.io import os.path import sys @@ -33,28 +33,28 @@ FIPNUM self.norne_fname = os.path.abspath('examples/data/norne/NORNE_ATW2013.DATA') def test_parse(self): - spe3 = opm.parser.parse(self.spe3fn) + spe3 = opm.io.parse(self.spe3fn) self.assertEqual('SPE 3 - CASE 1', spe3.state.title) def test_parse_with_recovery(self): - recovery = [("PARSE_RANDOM_SLASH", opm.parser.action.ignore)] - spe3 = opm.parser.parse(self.spe3fn, recovery=recovery) + recovery = [("PARSE_RANDOM_SLASH", opm.io.action.ignore)] + spe3 = opm.io.parse(self.spe3fn, recovery=recovery) def test_parse_with_multiple_recoveries(self): - recoveries = [ ("PARSE_RANDOM_SLASH", opm.parser.action.ignore), - ("FOO", opm.parser.action.warn), - ("PARSE_RANDOM_TEXT", opm.parser.action.throw) ] + recoveries = [ ("PARSE_RANDOM_SLASH", opm.io.action.ignore), + ("FOO", opm.io.action.warn), + ("PARSE_RANDOM_TEXT", opm.io.action.throw) ] - spe3 = opm.parser.parse(self.spe3fn, recovery=recoveries) + spe3 = opm.io.parse(self.spe3fn, recovery=recoveries) def test_throw_on_invalid_recovery(self): recoveries = [ ("PARSE_RANDOM_SLASH", 3.14 ) ] with self.assertRaises(TypeError): - opm.parser.parse(self.spe3fn, recovery=recoveries) + opm.io.parse(self.spe3fn, recovery=recoveries) with self.assertRaises(TypeError): - opm.parser.parse(self.spe3fn, recovery="PARSE_RANDOM_SLASH") + opm.io.parse(self.spe3fn, recovery="PARSE_RANDOM_SLASH") def test_data(self): pass @@ -62,7 +62,7 @@ FIPNUM #self.assertEqual([3,3,1,2], regtest.props()['OPERNUM']) def test_parse_norne(self): - state = opm.parser.parse(self.norne_fname, recovery=[('PARSE_RANDOM_SLASH', opm.parser.action.ignore)]) + state = opm.io.parse(self.norne_fname, recovery=[('PARSE_RANDOM_SLASH', opm.io.action.ignore)]) es = state.state self.assertEqual(46, es.grid().getNX()) self.assertEqual(112, es.grid().getNY()) diff --git a/python/tests/test_parse_deck.py b/python/tests/test_parse_deck.py index 5ba10cca6..fbbc9e9a1 100644 --- a/python/tests/test_parse_deck.py +++ b/python/tests/test_parse_deck.py @@ -1,6 +1,6 @@ import unittest import opm -import opm.parser +import opm.io import os.path class TestParse(unittest.TestCase): @@ -55,18 +55,18 @@ FIPNUM def test_IOError(self): with self.assertRaises(IOError): - opm.parser.load_deck("file/not/found") + opm.io.load_deck("file/not/found") def test_parser_fail_without_extension(self): - error_recovery = [("PARSE_RANDOM_SLASH", opm.parser.action.ignore)] + error_recovery = [("PARSE_RANDOM_SLASH", opm.io.action.ignore)] with self.assertRaises(ValueError): - opm.parser.load_deck_string(self.DECK_ADDITIONAL_KEYWORDS, + opm.io.load_deck_string(self.DECK_ADDITIONAL_KEYWORDS, recovery=error_recovery ) def test_parser_extension(self): - error_recovery = [("PARSE_RANDOM_SLASH", opm.parser.action.ignore)] - deck = opm.parser.load_deck_string(self.DECK_ADDITIONAL_KEYWORDS, + error_recovery = [("PARSE_RANDOM_SLASH", opm.io.action.ignore)] + deck = opm.io.load_deck_string(self.DECK_ADDITIONAL_KEYWORDS, keywords=self.KEYWORDS, recovery=error_recovery ) self.assertIn( 'TESTKEY0', deck ) diff --git a/python/tests/test_props.py b/python/tests/test_props.py index c00810ec2..5b25f7edf 100644 --- a/python/tests/test_props.py +++ b/python/tests/test_props.py @@ -1,5 +1,5 @@ import unittest -import opm.parser +import opm.io class TestProps(unittest.TestCase): @@ -9,7 +9,7 @@ class TestProps(unittest.TestCase): self.assertTrue(diff <= epsilon, msg=err_msg) def setUp(self): - self.spe3 = opm.parser.parse('tests/spe3/SPE3CASE1.DATA').state + self.spe3 = opm.io.parse('tests/spe3/SPE3CASE1.DATA').state self.props = self.spe3.props() def test_repr(self): diff --git a/python/tests/test_schedule.py b/python/tests/test_schedule.py index 84c1b4c8c..4cb06e582 100644 --- a/python/tests/test_schedule.py +++ b/python/tests/test_schedule.py @@ -1,8 +1,8 @@ import unittest import datetime as dt -import opm.parser.schedule -from opm.parser import parse +import opm.io.schedule +from opm.io import parse class TestSchedule(unittest.TestCase): @@ -37,8 +37,8 @@ class TestSchedule(unittest.TestCase): def head(xs): return next(iter(xs)) - inje = head(filter(opm.parser.schedule.Well.injector(), g1)) - prod = head(filter(opm.parser.schedule.Well.producer(), g1)) + inje = head(filter(opm.io.schedule.Well.injector(), g1)) + prod = head(filter(opm.io.schedule.Well.producer(), g1)) self.assertEqual(self.sch.get_well('INJ', 0).isinjector(), inje.isinjector()) self.assertEqual(self.sch.get_well('PROD', 0).isproducer(), prod.isproducer()) diff --git a/python/tests/test_state.py b/python/tests/test_state.py index e71718677..948014e4f 100644 --- a/python/tests/test_state.py +++ b/python/tests/test_state.py @@ -1,5 +1,5 @@ import unittest -import opm.parser +import opm.io class TestState(unittest.TestCase): FAULTS_DECK = """ @@ -49,8 +49,8 @@ SATNUM @classmethod def setUpClass(cls): - cls.spe3 = opm.parser.parse('tests/spe3/SPE3CASE1.DATA') - cpa = opm.parser.parse('tests/data/CORNERPOINT_ACTNUM.DATA') + cls.spe3 = opm.io.parse('tests/spe3/SPE3CASE1.DATA') + cpa = opm.io.parse('tests/data/CORNERPOINT_ACTNUM.DATA') cls.state = cls.spe3.state cls.cp_state = cpa.state @@ -124,7 +124,7 @@ SATNUM def test_faults(self): self.assertEquals([], self.state.faultNames()) self.assertEquals({}, self.state.faults()) - faultdeck = opm.parser.parse_string(self.FAULTS_DECK).state + faultdeck = opm.io.parse_string(self.FAULTS_DECK).state self.assertEqual(['F1', 'F2'], faultdeck.faultNames()) # 'F2' 5 5 1 4 1 4 'X-' / \n" f2 = faultdeck.faultFaces('F2') @@ -139,7 +139,7 @@ SATNUM # jf["OIL_WATER"] = 21.0 # set in deck # jf["GAS_OIL"] = -1.0 # N/A - js = opm.parser.parse('tests/data/JFUNC.DATA').state + js = opm.io.parse('tests/data/JFUNC.DATA').state self.assertEqual('JFUNC TEST', js.title) jf = js.jfunc() print(jf) @@ -167,7 +167,7 @@ JFUNC GAS * 13.0 0.6 0.7 Z / PROPS\nREGIONS """ - js_gas = opm.parser.parse_string(jfunc_gas).state + js_gas = opm.io.parse_string(jfunc_gas).state jf = js_gas.jfunc() self.assertEqual(jf['FLAG'], 'GAS') self.assertEqual(jf['DIRECTION'], 'Z') diff --git a/python/tests/test_time_vector.py b/python/tests/test_time_vector.py index 5d03044ef..7a80bbfc6 100644 --- a/python/tests/test_time_vector.py +++ b/python/tests/test_time_vector.py @@ -1,7 +1,7 @@ import unittest import datetime from opm.tools import * -from opm.parser import load_deck_string, load_deck +from opm.io import load_deck_string, load_deck from utils import tmp class TestTimeVector(unittest.TestCase): diff --git a/python/tests/test_wells.py b/python/tests/test_wells.py index d58e1068c..ca52abb19 100644 --- a/python/tests/test_wells.py +++ b/python/tests/test_wells.py @@ -1,6 +1,6 @@ import unittest import opm -from opm.parser import parse +from opm.io import parse class TestWells(unittest.TestCase): @@ -11,10 +11,10 @@ class TestWells(unittest.TestCase): # cls.wells = cls.sch.wells def inje(self, wells): - return next(iter(filter(opm.parser.schedule.Well.injector(), wells))) + return next(iter(filter(opm.io.schedule.Well.injector(), wells))) def prod(self, wells): - return next(iter(filter(opm.parser.schedule.Well.producer(), wells))) + return next(iter(filter(opm.io.schedule.Well.producer(), wells))) def testWellPos0(self): wells = self.sch.get_wells(0) @@ -64,14 +64,14 @@ class TestWells(unittest.TestCase): self.assertTrue(prod.available_gctrl()) def testWellDefinedFilter(self): - defined0 = list(filter(opm.parser.schedule.Well.defined(0), self.sch.get_wells(0) )) - defined1 = list(filter(opm.parser.schedule.Well.defined(1), self.sch.get_wells(1) )) + defined0 = list(filter(opm.io.schedule.Well.defined(0), self.sch.get_wells(0) )) + defined1 = list(filter(opm.io.schedule.Well.defined(1), self.sch.get_wells(1) )) self.assertEqual(len(list(defined0)), 2) self.assertEqual(len(list(defined1)), 2) def testWellProdInjeFilter(self): - inje = list(filter(opm.parser.schedule.Well.injector(), self.sch.get_wells(0) )) - prod = list(filter(opm.parser.schedule.Well.producer(), self.sch.get_wells(0) )) + inje = list(filter(opm.io.schedule.Well.injector(), self.sch.get_wells(0) )) + prod = list(filter(opm.io.schedule.Well.producer(), self.sch.get_wells(0) )) self.assertEqual(len(inje), 1) self.assertEqual(len(prod), 1) @@ -82,15 +82,15 @@ class TestWells(unittest.TestCase): def testOpenFilter(self): wells = self.sch.get_wells(1) - open_at_1 = opm.parser.schedule.Well.flowing() + open_at_1 = opm.io.schedule.Well.flowing() flowing = list(filter(open_at_1, wells)) closed = list(filter(lambda well: not open_at_1(well), wells)) self.assertEqual(2, len(flowing)) self.assertEqual(0, len(closed)) - flowing1 = filter(lambda x: not opm.parser.schedule.Well.closed()(x), wells) - closed1 = filter(opm.parser.schedule.Well.closed(), wells) + flowing1 = filter(lambda x: not opm.io.schedule.Well.closed()(x), wells) + closed1 = filter(opm.io.schedule.Well.closed(), wells) self.assertListEqual(list(closed), list(closed1)) def testCompletions(self):