-
Notifications
You must be signed in to change notification settings - Fork 18
/
startup.m
103 lines (91 loc) · 2.45 KB
/
startup.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
% avoid adding all the git directories to the path just by doing it
% manually for now ...
addpath('./algorithms');
addpath('./algorithms/test');
addpath('./algorithms/mex');
addpath('./misc');
addpath('./simulations');
addpath('./simulations/betakernel');
addpath('./simulations/misc');
addpath('./testfiles');
addpath('../minepy/matlab');
% setup for best results on parallel processing
if(ispc)
myCluster = parcluster('local');
myCluster.NumWorkers = 8;
saveProfile(myCluster);
elseif(ismac)
myCluster = parcluster('local');
myCluster.NumWorkers = 3;
saveProfile(myCluster);
elseif(isunix)
myCluster = parcluster('local');
myCluster.NumWorkers = 8;
saveProfile(myCluster);
end
% setup Python in Matlab if it isn't already loaded
if(isunix)
try
pyversion /usr/bin/python % assume python installed in default path
catch
try
pyversion 2.7
catch
end
end
else
try
pyversion 2.7 % assume you have Python 2.7 :D
catch
end
end
% add the python folder to the PYTHON search path
if count(py.sys.path,'./python') == 0
insert(py.sys.path,int32(0),'./python');
end
% python module dependencies check
requiredPythonModules = {'numpy', 'matplotlib', 'scipy', 'sklearn', 'cvxopt'};
for ii=1:length(requiredPythonModules)
modName = requiredPythonModules{ii};
try
py.importlib.import_module(modName);
catch ME
if (strcmp(ME.identifier,'MATLAB:Python:PyException'))
warning('Python Error! module: %s required for python extension modules!', modName);
end
end
end
% setup R BATCH commands to be callable from Matlab
PATH = getenv('PATH');
z = strsplit(PATH,':');
MAC_R_PATH = '/usr/local/bin';
UNIX_R_PATH = '/usr/bin';
WINDOWS_R_PATH = ''; % ?? -- prompt user?
if(ismac)
notFound = 1;
for ii=1:length(z)
if(strcmp(z{ii},MAC_R_PATH))
notFound = 0;
break;
end
end
if(notFound)
setenv('PATH', [PATH ':' MAC_R_PATH]);
end
elseif(isunix)
notFound = 1;
for ii=1:length(z)
if(strcmp(z{ii},UNIX_R_PATH))
notFound = 0;
break;
end
end
if(notFound)
setenv('PATH', [PATH ':' UNIX_R_PATH]);
end
else
% TODO: add path to R in Windows installation... prompt user?
end
% TODO: Required R-Packages dependency check??
requiredRPackages = {'SAM', 'energy', 'glasso', 'glmnet', ...
'pracma', 'pgraph'};