Skip to content

Commit f349c80

Browse files
committed
replace sub_process with interpreter
1 parent 07ded4b commit f349c80

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

PyStemmusScope/stemmus_scope.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ def _is_model_src_exe(model_src_path: Path):
3232
raise ValueError(msg)
3333

3434

35-
def _check_sub_process(sub_process: str):
36-
if sub_process not in {"Octave" , "Matlab"}:
35+
def _check_interpreter(interpreter: str):
36+
if interpreter not in {"Octave" , "Matlab"}:
3737
msg = (
38-
"Set `sub_process` as Octave or Matlab to run the model using source codes."
38+
"Set `interpreter` as Octave or Matlab to run the model using source codes."
3939
"Otherwise set `model_src_path` to the model executable file, "
4040
"see the documentaion.")
4141
raise ValueError(msg)
@@ -77,15 +77,15 @@ class StemmusScope():
7777
repository <https://github.com/EcoExtreML/STEMMUS_SCOPE_Processing>`_
7878
model_src_path(str): path to Stemmus_Scope executable file or to a
7979
directory containing model source codes.
80-
sub_process(str, optional): use `Matlab` or `Octave`. It is optional if
80+
interpreter(str, optional): use `Matlab` or `Octave`. It is optional if
8181
`model_src_path` is a path to Stemmus_Scope executable file.
8282
8383
Example:
8484
See notebooks/run_model_in_notebook.ipynb in `STEMMUS_SCOPE_Processing
8585
repository <https://github.com/EcoExtreML/STEMMUS_SCOPE_Processing>`_
8686
"""
8787

88-
def __init__(self, config_file: str, model_src_path: str, sub_process: str = None):
88+
def __init__(self, config_file: str, model_src_path: str, interpreter: str = None):
8989
# make sure paths are abolute and path objects
9090
config_file = utils.to_absolute_path(config_file)
9191
model_src_path = utils.to_absolute_path(model_src_path)
@@ -95,10 +95,10 @@ def __init__(self, config_file: str, model_src_path: str, sub_process: str = Non
9595
if _is_model_src_exe(model_src_path):
9696
self.exe_file = model_src_path
9797
else:
98-
_check_sub_process(sub_process)
98+
_check_interpreter(interpreter)
9999

100100
self.model_src = model_src_path
101-
self.sub_process = sub_process
101+
self.interpreter = interpreter
102102

103103
# read config template
104104
self._config = config_io.read_config(config_file)
@@ -163,7 +163,7 @@ def run(self) -> str:
163163
# set matlab log dir
164164
os.environ['MATLAB_LOG_DIR'] = str(self._config["InputPath"])
165165
result = _run_sub_process(args, None)
166-
if self.sub_process=="Matlab":
166+
if self.interpreter=="Matlab":
167167
# set Matlab arguments
168168
path_to_config = f"'{self.cfg_file}'"
169169
eval_code= f'STEMMUS_SCOPE_exe({path_to_config});exit;'
@@ -172,7 +172,7 @@ def run(self) -> str:
172172
if utils.os_name() !="nt":
173173
args = shlex.join(args)
174174
result = _run_sub_process(args, self.model_src)
175-
if self.sub_process=="Octave":
175+
if self.interpreter=="Octave":
176176
# set Octave arguments
177177
# use subprocess instead of oct2py,
178178
# see issue STEMMUS_SCOPE_Processing/issues/46

notebooks/run_model_in_notebook.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
"outputs": [],
183183
"source": [
184184
"# create an an instance of the model\n",
185-
"model = StemmusScope(config_file=path_to_config_file, model_src_path=path_to_model_src, sub_process=\"Matlab\")"
185+
"model = StemmusScope(config_file=path_to_config_file, model_src_path=path_to_model_src, interpreter=\"Matlab\")"
186186
]
187187
},
188188
{
@@ -286,7 +286,7 @@
286286
"outputs": [],
287287
"source": [
288288
"# create an an instance of the model\n",
289-
"model = StemmusScope(config_file=path_to_config_file, model_src_path=path_to_model_src, sub_process=\"Octave\")"
289+
"model = StemmusScope(config_file=path_to_config_file, model_src_path=path_to_model_src, interpreter=\"Octave\")"
290290
]
291291
},
292292
{
@@ -374,7 +374,7 @@
374374
"hash": "28b136f154b3384fcb2854e5626613232692c304dbc5315064ef4c9363104a2c"
375375
},
376376
"kernelspec": {
377-
"display_name": "Python",
377+
"display_name": "Python 3 (ipykernel)",
378378
"language": "python",
379379
"name": "python3"
380380
},
@@ -388,7 +388,7 @@
388388
"name": "python",
389389
"nbconvert_exporter": "python",
390390
"pygments_lexer": "ipython3",
391-
"version": "3.8.10"
391+
"version": "3.9.12"
392392
}
393393
},
394394
"nbformat": 4,

tests/test_stemmus_scope.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ def test_model_without_src(self):
2424
StemmusScope(config_file, model_src_path="src")
2525
assert "Provide a valid path to an executable file" in str(excinfo.value)
2626

27-
def test_model_without_subprocess(self, tmp_path):
27+
def test_model_without_interpreter(self, tmp_path):
2828
config_file = str(data_folder / "config_file_test.txt")
2929
with pytest.raises(ValueError) as excinfo:
3030
StemmusScope(config_file, model_src_path=tmp_path)
31-
assert "Set `sub_process` as Octave or Matlab" in str(excinfo.value)
31+
assert "Set `interpreter` as Octave or Matlab" in str(excinfo.value)
3232

33-
def test_model_wrong_subprocess(self, tmp_path):
33+
def test_model_wrong_interpreter(self, tmp_path):
3434
config_file = str(data_folder / "config_file_test.txt")
3535
with pytest.raises(ValueError) as excinfo:
36-
StemmusScope(config_file, model_src_path=tmp_path, sub_process="Nothing")
37-
assert "Set `sub_process` as Octave or Matlab" in str(excinfo.value)
36+
StemmusScope(config_file, model_src_path=tmp_path, interpreter="Nothing")
37+
assert "Set `interpreter` as Octave or Matlab" in str(excinfo.value)
3838

3939

4040
class TestWithDefaults:
@@ -174,7 +174,7 @@ class TestWithMatlab:
174174
@pytest.fixture
175175
def model(self, tmp_path):
176176
config_file = str(data_folder / "config_file_test.txt")
177-
yield StemmusScope(config_file, model_src_path=tmp_path, sub_process="Matlab")
177+
yield StemmusScope(config_file, model_src_path=tmp_path, interpreter="Matlab")
178178

179179
@pytest.fixture
180180
def model_with_setup(self, model):
@@ -226,7 +226,7 @@ class TestWithOctave:
226226
@pytest.fixture
227227
def model(self, tmp_path):
228228
config_file = str(data_folder / "config_file_test.txt")
229-
yield StemmusScope(config_file, model_src_path=tmp_path, sub_process="Octave")
229+
yield StemmusScope(config_file, model_src_path=tmp_path, interpreter="Octave")
230230

231231
@pytest.fixture
232232
def model_with_setup(self, model):

0 commit comments

Comments
 (0)