Skip to content

Commit a482574

Browse files
committed
more changes
1 parent 76ed1e4 commit a482574

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

RATapi/examples/normal_reflectivity/DSPC_custom_layers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ def DSPC_custom_layers():
127127

128128
if __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)

RATapi/wrappers.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Wrappers for the interface between RATapi and MATLAB custom files."""
2+
from contextlib import contextmanager
23
import os
34
import pathlib
45
import platform
@@ -15,6 +16,16 @@
1516
MATLAB_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+
1829
def 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

cpp/rat.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff 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

2926
namespace py = pybind11;
3027

0 commit comments

Comments
 (0)