From e5987c26d7abe9e3fe3fec3309c5d753913572a1 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 19 Sep 2019 11:14:40 +0200 Subject: [PATCH] #4736 Case.py renames --- .../GrpcInterface/Python/rips/Case.py | 68 +++++++++---------- .../GrpcInterface/Python/rips/Commands.py | 2 +- .../Python/rips/PythonExamples/AllCases.py | 4 +- .../CaseInfoStreamingExample.py | 4 +- .../rips/PythonExamples/ExportSnapshots.py | 4 +- .../LaunchWithCommandLineOptions.py | 2 +- .../rips/PythonExamples/SetGridProperties.py | 2 +- .../rips/PythonExamples/SoilAverageAsync.py | 2 +- .../rips/PythonExamples/SoilAverageSync.py | 2 +- .../rips/PythonExamples/SoilPorvAsync.py | 2 +- .../rips/PythonExamples/SoilPorvSync.py | 2 +- .../Python/rips/tests/test_cases.py | 16 ++--- .../Python/rips/tests/test_grids.py | 2 +- 13 files changed, 56 insertions(+), 56 deletions(-) diff --git a/ApplicationCode/GrpcInterface/Python/rips/Case.py b/ApplicationCode/GrpcInterface/Python/rips/Case.py index 312bfab25d..34b38f5996 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/Case.py +++ b/ApplicationCode/GrpcInterface/Python/rips/Case.py @@ -31,13 +31,13 @@ class Case (PdmObject): self.id = id info = self.stub.GetCaseInfo(Case_pb2.CaseRequest(id=self.id)) self.name = info.name - self.groupId = info.group_id + self.group_id = info.group_id self.type = info.type self.properties = Properties(self) self.request = Case_pb2.CaseRequest(id=self.id) PdmObject.__init__(self, self.stub.GetPdmObject(self.request), self.channel) - def gridCount(self): + def grid_count(self): """Get number of grids in the case""" try: return self.stub.GetGridCount(self.request).count @@ -47,7 +47,7 @@ class Case (PdmObject): print("ERROR: ", e) return 0 - def gridPath(self): + def grid_path(self): return self.getValue("CaseFileName") def grid(self, index): @@ -62,50 +62,50 @@ class Case (PdmObject): def grids(self): """Get a list of all rips Grid objects in the case""" - gridList = [] - for i in range(0, self.gridCount()): - gridList.append(Grid(i, self)) - return gridList + grid_list = [] + for i in range(0, self.grid_count()): + grid_list.append(Grid(i, self)) + return grid_list - def cellCount(self, porosityModel='MATRIX_MODEL'): + def cell_count(self, porosity_model='MATRIX_MODEL'): """Get a cell count object containing number of active cells and total number of cells Arguments: - porosityModel (str): String representing an enum. + porosity_model (str): String representing an enum. must be 'MATRIX_MODEL' or 'FRACTURE_MODEL'. Returns: Cell Count object with the following integer attributes: active_cell_count: number of active cells reservoir_cell_count: total number of reservoir cells """ - porosityModelEnum = Case_pb2.PorosityModelType.Value(porosityModel) + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) request = Case_pb2.CellInfoRequest(case_request=self.request, - porosity_model=porosityModel) + porosity_model=porosity_model_enum) return self.stub.GetCellCount(request) - def cellInfoForActiveCellsAsync(self, porosityModel='MATRIX_MODEL'): + def cell_info_for_active_cells_async(self, porosity_model='MATRIX_MODEL'): """Get Stream of cell info objects for current case Arguments: - porosityModel(str): String representing an enum. + porosity_model(str): String representing an enum. must be 'MATRIX_MODEL' or 'FRACTURE_MODEL'. Returns: Stream of **CellInfo** objects - See cellInfoForActiveCells() for detalis on the **CellInfo** class. + See cell_info_for_active_cells() for detalis on the **CellInfo** class. """ - porosityModelEnum = Case_pb2.PorosityModelType.Value(porosityModel) + porosity_model_enum = Case_pb2.PorosityModelType.Value(porosity_model) request = Case_pb2.CellInfoRequest(case_request=self.request, - porosity_model=porosityModel) + porosity_model=porosity_model_enum) return self.stub.GetCellInfoForActiveCells(request) - def cellInfoForActiveCells(self, porosityModel='MATRIX_MODEL'): + def cell_info_for_active_cells(self, porosity_model='MATRIX_MODEL'): """Get list of cell info objects for current case Arguments: - porosityModel(str): String representing an enum. + porosity_model(str): String representing an enum. must be 'MATRIX_MODEL' or 'FRACTURE_MODEL'. Returns: @@ -130,14 +130,14 @@ class Case (PdmObject): k | K grid index | Integer """ - activeCellInfoChunks = self.cellInfoForActiveCellsAsync() - receivedActiveCells = [] - for activeCellChunk in activeCellInfoChunks: + active_cell_info_chunks = self.cell_info_for_active_cells_async() + received_active_cells = [] + for activeCellChunk in active_cell_info_chunks: for activeCell in activeCellChunk.data: - receivedActiveCells.append(activeCell) - return receivedActiveCells + received_active_cells.append(activeCell) + return received_active_cells - def timeSteps(self): + def time_steps(self): """Get a list containing all time steps The time steps are defined by the class **TimeStepDate** : @@ -155,16 +155,16 @@ class Case (PdmObject): """ return self.stub.GetTimeSteps(self.request).dates - def daysSinceStart(self): + def days_since_start(self): """Get a list of decimal values representing days since the start of the simulation""" return self.stub.GetDaysSinceStart(self.request).day_decimals def views(self): """Get a list of views belonging to a case""" - pbmObjects = self.children("ReservoirViews") + pdm_objects = self.children("ReservoirViews") viewList = [] - for pbmObject in pbmObjects: - viewList.append(View(pbmObject)) + for pdm_object in pdm_objects: + viewList.append(View(pdm_object)) return viewList def view(self, id): @@ -176,13 +176,13 @@ class Case (PdmObject): """ views = self.views() - for viewObject in views: - if viewObject.id == id: - return viewObject + for view_object in views: + if view_object.id == id: + return view_object return None - def createView(self): + def create_view(self): """Create a new view in the current case""" - viewId = Commands(self.channel).createView(self.id) - return self.view(viewId) + view_id = Commands(self.channel).create_view(self.id) + return self.view(view_id) diff --git a/ApplicationCode/GrpcInterface/Python/rips/Commands.py b/ApplicationCode/GrpcInterface/Python/rips/Commands.py index b80d84405d..6ecdc443c1 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/Commands.py +++ b/ApplicationCode/GrpcInterface/Python/rips/Commands.py @@ -289,7 +289,7 @@ class Commands: minimumCommunication = minimumCommunication, aquiferCellThreshold = aquiferCellThreshold)) - def createView(self, caseId): + def create_view(self, caseId): return self.__execute(createView=Cmd.CreateViewRequest(caseId=caseId)).createViewResult.viewId def cloneView(self, viewId): diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/AllCases.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/AllCases.py index 51d07a0b44..d42ba2ce9a 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/AllCases.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/AllCases.py @@ -15,9 +15,9 @@ if resInsight is not None: print ("Got " + str(len(cases)) + " cases: ") for case in cases: print("Case name: " + case.name) - print("Case grid path: " + case.gridPath()) + print("Case grid path: " + case.grid_path()) - timesteps = case.timeSteps() + timesteps = case.time_steps() for t in timesteps: print("Year: " + str(t.year)) print("Month: " + str(t.month)) diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/CaseInfoStreamingExample.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/CaseInfoStreamingExample.py index 6f81aa0693..ccec7d14bb 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/CaseInfoStreamingExample.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/CaseInfoStreamingExample.py @@ -12,12 +12,12 @@ resInsight = rips.Instance.find() case = resInsight.project.case(id = 0) # Get the cell count object -cellCounts = case.cellCount() +cellCounts = case.cell_count() print("Number of active cells: " + str(cellCounts.active_cell_count)) print("Total number of reservoir cells: " + str(cellCounts.reservoir_cell_count)) # Get information for all active cells -activeCellInfos = case.cellInfoForActiveCells() +activeCellInfos = case.cell_info_for_active_cells() # A simple check on the size of the cell info assert(cellCounts.active_cell_count == len(activeCellInfos)) diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/ExportSnapshots.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/ExportSnapshots.py index 69f71f80cc..0a5ebac411 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/ExportSnapshots.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/ExportSnapshots.py @@ -18,7 +18,7 @@ property_list = ['SOIL', 'PRESSURE'] # list of parameter for snapshot print ("Looping through cases") for case in cases: # Get grid path and its folder name - casepath = case.gridPath() + casepath = case.grid_path() foldername = os.path.dirname(casepath) # create a folder to hold the snapshots @@ -30,7 +30,7 @@ for case in cases: print ("Exporting to folder: " + dirname) resInsight.commands.setExportFolder(type='SNAPSHOTS', path=dirname) - timeSteps = case.timeSteps() + timeSteps = case.time_steps() tss_snapshot = range(0, len(timeSteps), n) print(case.name, case.id, 'Number of timesteps: ' + str(len(timeSteps))) print('Number of timesteps for snapshoting: ' + str(len(tss_snapshot))) diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/LaunchWithCommandLineOptions.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/LaunchWithCommandLineOptions.py index ae6975408e..8ac0ce6917 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/LaunchWithCommandLineOptions.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/LaunchWithCommandLineOptions.py @@ -8,4 +8,4 @@ cases = resInsight.project.cases() print ("Got " + str(len(cases)) + " cases: ") for case in cases: print("Case name: " + case.name) - print("Case grid path: " + case.gridPath()) + print("Case grid path: " + case.grid_path()) diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SetGridProperties.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SetGridProperties.py index a7f8f7878b..1df32dc455 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SetGridProperties.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SetGridProperties.py @@ -6,7 +6,7 @@ import rips resInsight = rips.Instance.find() case = resInsight.project.case(id=0) -totalCellCount = case.cellCount().reservoir_cell_count +totalCellCount = case.cell_count().reservoir_cell_count values = [] for i in range(0, totalCellCount): diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilAverageAsync.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilAverageAsync.py index b6eccc186d..f6d390a70f 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilAverageAsync.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilAverageAsync.py @@ -14,7 +14,7 @@ start = time.time() case = resInsight.project.case(id=0) # Get a list of all time steps -timeSteps = case.timeSteps() +timeSteps = case.time_steps() averages = [] for i in range(0, len(timeSteps)): diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilAverageSync.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilAverageSync.py index 7b3b879689..0ee7b5c872 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilAverageSync.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilAverageSync.py @@ -14,7 +14,7 @@ case = resInsight.project.case(id=0) case = resInsight.project.case(id=0) # Get a list of all time steps -timeSteps = case.timeSteps() +timeSteps = case.time_steps() averages = [] for i in range(0, len(timeSteps)): diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilPorvAsync.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilPorvAsync.py index 2c8bd954de..566b1bbdb3 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilPorvAsync.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilPorvAsync.py @@ -19,7 +19,7 @@ def createResult(soilChunks, porvChunks): resInsight = rips.Instance.find() start = time.time() case = resInsight.project.case(id=0) -timeStepInfo = case.timeSteps() +timeStepInfo = case.time_steps() # Get a generator for the porv results. The generator will provide a chunk each time it is iterated porvChunks = case.properties.activeCellPropertyAsync('STATIC_NATIVE', 'PORV', 0) diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilPorvSync.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilPorvSync.py index 53684a211b..9a2fe52d9d 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilPorvSync.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/SoilPorvSync.py @@ -11,7 +11,7 @@ case = resInsight.project.case(id=0) # Read the full porv result porvResults = case.properties.activeCellProperty('STATIC_NATIVE', 'PORV', 0) -timeStepInfo = case.timeSteps() +timeStepInfo = case.time_steps() for i in range (0, len(timeStepInfo)): # Read the full SOIl result for time step i diff --git a/ApplicationCode/GrpcInterface/Python/rips/tests/test_cases.py b/ApplicationCode/GrpcInterface/Python/rips/tests/test_cases.py index 76e198ce05..865acb82a8 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/tests/test_cases.py +++ b/ApplicationCode/GrpcInterface/Python/rips/tests/test_cases.py @@ -41,13 +41,13 @@ def test_MultipleCases(rips_instance, initializeTest): def test_10k(rips_instance, initializeTest): casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID" case = rips_instance.project.loadCase(path=casePath) - assert(case.gridCount() == 2) - cellCountInfo = case.cellCount() + assert(case.grid_count() == 2) + cellCountInfo = case.cell_count() assert(cellCountInfo.active_cell_count == 11125) assert(cellCountInfo.reservoir_cell_count == 316224) - timeSteps = case.timeSteps() + timeSteps = case.time_steps() assert(len(timeSteps) == 9) - daysSinceStart = case.daysSinceStart() + daysSinceStart = case.days_since_start() assert(len(daysSinceStart) == 9) def test_PdmObject(rips_instance, initializeTest): @@ -63,13 +63,13 @@ def test_PdmObject(rips_instance, initializeTest): def test_brugge_0010(rips_instance, initializeTest): casePath = dataroot.PATH + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID" case = rips_instance.project.loadCase(path=casePath) - assert(case.gridCount() == 1) - cellCountInfo = case.cellCount() + assert(case.grid_count() == 1) + cellCountInfo = case.cell_count() assert(cellCountInfo.active_cell_count == 43374) assert(cellCountInfo.reservoir_cell_count == 60048) - timeSteps = case.timeSteps() + timeSteps = case.time_steps() assert(len(timeSteps) == 11) - daysSinceStart = case.daysSinceStart() + daysSinceStart = case.days_since_start() assert(len(daysSinceStart) == 11) @pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux") diff --git a/ApplicationCode/GrpcInterface/Python/rips/tests/test_grids.py b/ApplicationCode/GrpcInterface/Python/rips/tests/test_grids.py index 52556d94da..8b2d93c0b9 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/tests/test_grids.py +++ b/ApplicationCode/GrpcInterface/Python/rips/tests/test_grids.py @@ -9,7 +9,7 @@ import dataroot def test_10k(rips_instance, initializeTest): casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID" case = rips_instance.project.loadCase(path=casePath) - assert(case.gridCount() == 2) + assert(case.grid_count() == 2) grid = case.grid(index=0) dimensions = grid.dimensions() assert(dimensions.i == 90)