Skip to content

Commit

Permalink
Fix missing import in gravimetry
Browse files Browse the repository at this point in the history
Because cwrapped functions need classes to be defined for
all of their inputs, we need to import them.

Added type hints to avoid linters complaining about unused
imports.
  • Loading branch information
eivindjahren committed Oct 31, 2023
1 parent 7b269d9 commit 6a6a52d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions python/ecl/gravimetry/ecl_grav.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
different surveys. The implementation is a thin wrapper around the
ecl_grav.c implementation in the libecl library.
"""
from typing import Optional

from cwrap import BaseCClass

from ecl import EclPrototype
from ecl.grid import EclGrid, EclRegion
from ecl.eclfile import EclFileView, EclFile
from ecl.util.util import monkey_the_camel
from ecl import EclPhaseEnum
import ecl.eclfile


class EclGrav(BaseCClass):
Expand Down Expand Up @@ -56,12 +59,9 @@ class is focused on the ECLIPSE side of things, and does not have
"double ecl_grav_eval(ecl_grav, char*, char*, ecl_region, double, double, double, int)"
)

def __init__(self, grid, init_file):
def __init__(self, grid: EclGrid, init_file: EclFile):
"""
Creates a new EclGrav instance.
The input arguments @grid and @init_file should be instances
of EclGrid and EclFile respectively.
"""
self.init_file = init_file # Inhibit premature garbage collection of init_file

Expand All @@ -75,7 +75,7 @@ def __init__(self, grid, init_file):
"RPORV": self.add_survey_RPORV,
}

def add_survey_RPORV(self, survey_name, restart_view):
def add_survey_RPORV(self, survey_name: str, restart_view: EclFileView):
"""
Add new survey based on RPORV keyword.
Expand All @@ -87,11 +87,11 @@ def add_survey_RPORV(self, survey_name, restart_view):
to load the @restart_view argument is:
import datetime
from ecl.ecl import EclRestartFile
from ecl.eclfile import EclFile
...
...
date = datetime.datetime(year, month, day)
rst_file = EclRestartFile("ECLIPSE.UNRST")
rst_file = EclFile("ECLIPSE.UNRST")
restart_view1 = rst_file.restartView(sim_time=date)
restart_view2 = rst_file.restartView(report_step=67)
Expand All @@ -102,7 +102,7 @@ def add_survey_RPORV(self, survey_name, restart_view):
"""
self._add_survey_RPORV(survey_name, restart_view)

def add_survey_PORMOD(self, survey_name, restart_view):
def add_survey_PORMOD(self, survey_name: str, restart_view: EclFileView):
"""
Add new survey based on PORMOD keyword.
Expand All @@ -112,7 +112,7 @@ def add_survey_PORMOD(self, survey_name, restart_view):
"""
self._add_survey_PORMOD(survey_name, restart_view)

def add_survey_FIP(self, survey_name, restart_view):
def add_survey_FIP(self, survey_name: str, restart_view: EclFileView):
"""
Add new survey based on FIP keywords.
Expand All @@ -127,7 +127,7 @@ def add_survey_FIP(self, survey_name, restart_view):
"""
self._add_survey_FIP(survey_name, restart_view)

def add_survey_RFIP(self, survey_name, restart_view):
def add_survey_RFIP(self, survey_name: str, restart_view: EclFileView):
"""
Add new survey based on RFIP keywords.
Expand All @@ -138,7 +138,7 @@ def add_survey_RFIP(self, survey_name, restart_view):
"""
self._add_survey_RFIP(survey_name, restart_view)

def add_survey(self, name, restart_view, method):
def add_survey(self, name: str, restart_view: EclFileView, method):
method = self.dispatch[method]
return method(name, restart_view)

Expand All @@ -147,7 +147,7 @@ def eval(
base_survey,
monitor_survey,
pos,
region=None,
region: Optional[EclRegion]=None,
phase_mask=EclPhaseEnum.ECL_OIL_PHASE
+ EclPhaseEnum.ECL_GAS_PHASE
+ EclPhaseEnum.ECL_WATER_PHASE,
Expand Down

0 comments on commit 6a6a52d

Please sign in to comment.