File tree Expand file tree Collapse file tree 3 files changed +20
-9
lines changed
examples/normal_reflectivity Expand file tree Collapse file tree 3 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -127,4 +127,4 @@ def DSPC_custom_layers():
127127
128128if __name__ == "__main__" :
129129 problem , results = DSPC_custom_layers ()
130- # RAT.plotting.plot_ref_sld(problem, results, True)
130+ RAT .plotting .plot_ref_sld (problem , results , True )
Original file line number Diff line number Diff line change 11"""Wrappers for the interface between RATapi and MATLAB custom files."""
2+ from contextlib import contextmanager
23import os
34import pathlib
45import platform
1516MATLAB_PATH_FILE = os .path .join (os .path .dirname (os .path .realpath (__file__ )), "matlab.txt" )
1617
1718
19+ @contextmanager
20+ def cd (newdir ):
21+ prev_dir = os .getcwd ()
22+ os .chdir (os .path .expanduser (newdir ))
23+ try :
24+ yield
25+ finally :
26+ os .chdir (prev_dir )
27+
28+
1829def set_matlab_path (matlab_path ):
1930 if not matlab_path :
2031 return
@@ -39,7 +50,7 @@ def get_matlab_paths(exe_path):
3950 if platform .system () == "Windows" :
4051 arch = "win64"
4152 elif platform .system () == "Darwin" :
42- arch = "maci64 " if ( bin_path / "maci64" ). exists () else "maca64 "
53+ arch = "maca64 " if platform . mac_ver ()[ - 1 ] == 'arm64' else "maci64 "
4354 else :
4455 arch = "glnxa64"
4556
@@ -78,10 +89,13 @@ def start_matlab():
7889 if matlab_path :
7990 bin_path , dll_path = get_matlab_paths (matlab_path )
8091 os .environ ["MATLAB_DLL_PATH" ] = dll_path
81- os .environ ["PATH" ] = bin_path + os .pathsep + os .environ ["PATH" ]
82- os .environ ["PATH" ] = dll_path + os .pathsep + os .environ ["PATH" ]
83- engine = RATapi .rat_core .MatlabEngine ()
84-
92+ print (bin_path , dll_path )
93+ if platform .system () == "Windows" :
94+ os .environ ["PATH" ] = dll_path + os .pathsep + os .environ ["PATH" ]
95+
96+ with cd (bin_path ):
97+ engine = RATapi .rat_core .MatlabEngine ()
98+
8599 return engine
86100
87101
Original file line number Diff line number Diff line change @@ -22,9 +22,6 @@ setup_pybind11(cfg)
2222#include " includes/defines.h"
2323#include " includes/functions.h"
2424
25- #include < chrono>
26- #include < thread>
27-
2825
2926namespace py = pybind11;
3027
You can’t perform that action at this time.
0 commit comments