Skip to content

Commit 2e318b2

Browse files
author
IvanARashid
committed
Added check to see if root dir is in pytohnpath, if not, method is not executed.
1 parent 584710e commit 2e318b2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/wrappers/OsipiBase.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import numpy as np
22
import importlib
33
from scipy.stats import norm
4-
4+
import pathlib
5+
import sys
56

67
class OsipiBase:
78
"""The base class for OSIPI IVIM fitting"""
@@ -29,11 +30,16 @@ def osipi_initiate_algorithm(self, algorithm, **kwargs):
2930
"""
3031

3132
# Import the algorithm
33+
root_path = pathlib.Path(__file__).resolve().parents[2]
34+
if str(root_path) not in sys.path:
35+
print("Root folder not in PYTHONPATH")
36+
return False
37+
3238
import_base_path = "src.standardized"
3339
import_path = import_base_path + "." + algorithm
3440
#Algorithm = getattr(importlib.import_module(import_path), algorithm)
3541
# Change the class from OsipiBase to the specified algorithm
36-
self.__class__ = getattr(importlib.import_module(import_path), algorithm)
42+
self.__class__ = getattr(importlib.import_module(import_path, package=package), algorithm)
3743
self.__init__(**kwargs)
3844

3945
def osipi_fit(self, data=None, bvalues=None, thresholds=None, bounds=None, initial_guess=None, **kwargs):

0 commit comments

Comments
 (0)