Skip to content

Commit

Permalink
Defer MCR packages import
Browse files Browse the repository at this point in the history
  • Loading branch information
gmrukwa committed Oct 26, 2019
1 parent 1354eec commit 78a21cf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions divik/_matlab_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,15 @@ def _matlab_paths():
os.environ['LD_LIBRARY_PATH'] = old_env
logging.log(logging.DEBUG, os.environ['LD_LIBRARY_PATH'])


with _matlab_paths():
import MatlabAlgorithms.MsiAlgorithms as msi
import matlab

_engine = None


def _ensure_engine():
global _engine
if _engine is None:
with _matlab_paths():
import MatlabAlgorithms.MsiAlgorithms as msi
import matlab
_engine = msi.initialize()
return _engine

Expand All @@ -73,6 +71,8 @@ def find_thresholds(values: np.ndarray, max_components: int = 10,
"""
with _matlab_paths():
engine = _ensure_engine()
import MatlabAlgorithms.MsiAlgorithms as msi
import matlab
values = matlab.double([[element] for element in values.ravel()])
try:
thresholds = engine.fetch_thresholds(values,
Expand Down

0 comments on commit 78a21cf

Please sign in to comment.