Skip to content

Commit 4e4a6dc

Browse files
fix right location for matlab avail
1 parent fc31bc6 commit 4e4a6dc

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

conftest.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import csv
55
# import datetime
66

7-
87
def pytest_addoption(parser):
98
parser.addoption(
109
"--SNR",
@@ -81,6 +80,22 @@ def pytest_addoption(parser):
8180
type=str,
8281
help="Drop this algorithm from the list"
8382
)
83+
parser.addoption(
84+
"--with-matlab",
85+
action="store_true",
86+
default=False,
87+
help="Run MATLAB-dependent tests"
88+
)
89+
90+
eng = None
91+
92+
def pytest_configure(config):
93+
global eng
94+
if config.getoption("--with-matlab"):
95+
import matlab.engine
96+
print("Starting MATLAB engine...")
97+
eng = matlab.engine.start_matlab()
98+
print("MATLAB engine started.")
8499

85100

86101
@pytest.fixture(scope="session")

tests/IVIMmodels/unit_tests/algorithms.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"OJ_GU_seg"
1717
],
1818
"ASD_MemorialSloanKettering_QAMPER_IVIM": {
19-
"requieres_matlab": true,
19+
"requieres_matlab": true
2020
},
2121
"IAR_LU_biexp": {
2222
"fail_first_time": true

tests/IVIMmodels/unit_tests/test_ivim_fit.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,10 @@
55
import pathlib
66
import time
77
from src.wrappers.OsipiBase import OsipiBase
8+
from conftest import eng
89
#run using python -m pytest from the root folder
910

1011

11-
eng = None
12-
13-
def pytest_addoption(parser):
14-
parser.addoption(
15-
"--with-matlab", action="store_true", default=False, help="Run MATLAB-dependent tests"
16-
)
17-
18-
@pytest.hookimpl
19-
def pytest_configure(config):
20-
global eng
21-
if config.getoption("--with-matlab"):
22-
import matlab.engine
23-
eng = matlab.engine.start_matlab()
24-
25-
2612
def signal_helper(signal):
2713
signal = np.asarray(signal)
2814
#signal[signal < 0] = 0.00001
@@ -72,7 +58,7 @@ def data_ivim_fit_saved():
7258
if first == True:
7359
if algorithm_dict.get("fail_first_time", {}) == True:
7460
skiptime = True
75-
first = False # this will only work for 1 algorithm... If two algorithms use fail_first_time, the second will not see it is the first time.
61+
first = False
7662
if algorithm_dict.get("requieres_matlab", {}) == True:
7763
if eng is None:
7864
continue
@@ -130,7 +116,7 @@ def algorithmlist():
130116
if eng is None:
131117
continue
132118
else:
133-
kwargs = {**kwargs, 'eng': eng}
119+
args = {**args, 'eng': eng}
134120
yield algorithm, args
135121

136122
@pytest.mark.parametrize("algorithm, args", algorithmlist())

0 commit comments

Comments
 (0)