Various MATLAB R2014a compatibility fixes

pac-components
Sébastien Villemot 2021-09-08 12:52:47 +02:00
parent 8d4f5fbd9b
commit e42cf2e5b4
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
7 changed files with 51 additions and 27 deletions

View File

@ -98,7 +98,11 @@ if T_max > 0
for i = T_max-1:-1:1
tmp = 0*binding_indicator;
tmp(1:end-i+1,:) = binding_indicator(i:end,:);
itmp = find(~any(dictionary.binding_indicator(1:length(tmp)*2,:)-tmp(:)));
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
itmp = find(~any(bsxfun(@minus, dictionary.binding_indicator(1:length(tmp)*2,:), tmp(:))));
else
itmp = find(~any(dictionary.binding_indicator(1:length(tmp)*2,:)-tmp(:)));
end
if ~isempty(itmp)
ireg(i) = itmp;
else
@ -166,4 +170,4 @@ for irfpos=2:n_periods+1
end
end
zdata = history(:,2:end)';
zdata = history(:,2:end)';

View File

@ -89,7 +89,11 @@ if T_max > 0
tmp = 0*binding_indicator;
tmp(1:end-i+1) = binding_indicator(i:end);
itmp = find(~any(dictionary.binding_indicator-tmp));
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
itmp = find(~any(bsxfun(@minus, dictionary.binding_indicator, tmp)));
else
itmp = find(~any(dictionary.binding_indicator-tmp));
end
if ~isempty(itmp)
ireg(i) = itmp;
else
@ -148,4 +152,4 @@ for irfpos=2:n_periods+1
end
end
zdata = history(:,2:end)';
zdata = history(:,2:end)';

View File

@ -74,9 +74,17 @@ end
% add back steady state
if ~options_.occbin.simul.piecewise_only
out.linear = out.linear + out.ys';
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
out.linear = bsxfun(@plus, out.linear, out.ys');
else
out.linear = out.linear + out.ys';
end
end
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
out.piecewise = bsxfun(@plus, out.piecewise, out.ys');
else
out.piecewise = out.piecewise + out.ys';
end
out.piecewise = out.piecewise+ out.ys';
out.exo_pos = options_.occbin.simul.exo_pos;
oo_.occbin=out;

View File

@ -51,14 +51,18 @@ else
xlsmat{tp,5}=int2str(regime_history(tp).regimestart2);
end
end
filename=[OutputDirectoryName filesep xls_filename '.xls'];
if matlab_ver_less_than('9.3')
if exist(filename,'file')
delete(filename)
end
if ~ispc && ~isoctave && matlab_ver_less_than('9.0')
% On GNU/Linux and macOS, with MATLAB < R2016a, “writeable” cant write Excel files
warning('This version of MATLAB is too old and cannot create Excel files. The Occbin regimes will rather be written to a CSV file')
filename=[OutputDirectoryName filesep xls_filename '.csv'];
else
if isfile(filename)
delete(filename)
end
filename=[OutputDirectoryName filesep xls_filename '.xls'];
end
if isfile(filename)
delete(filename)
end
if ~ispc && ~isoctave && matlab_ver_less_than('9.0') % See above
writetable(array2table(xlsmat,'VariableNames',Header), filename);
else
writetable(array2table(xlsmat,'VariableNames',Header), filename, 'Sheet', 'Regimes');
end
writetable(array2table(xlsmat,'VariableNames',Header), filename, 'Sheet', 'Regimes');

View File

@ -206,8 +206,8 @@ else
0.480506381923643
-0.111002148299648
1.000000000000000];
if max(abs(BETA' - good)) > 1e-14
error(['sum of BETA'' - good was: ' num2str(sum(abs(BETA - good)))]);
if max(abs(BETA' - good)) > 2e-14
error(['sum of BETA'' - good was: ' num2str(sum(abs(BETA' - good)))]);
end
return
end

View File

@ -21,14 +21,14 @@ M.orig_maximum_lag = 2;
caller = 'INITVAL';
options = struct();
options.series = "ds";
options.series = 'ds';
ds1 = histvalf_initvalf(caller, M, options);
failed_tests = my_assert(failed_tests, all(all(ds1 == ds)), 'basic test');
num_tests = num_tests + 1;
options = struct();
options.series = "ds1";
options.series = 'ds1';
options.first_obs = 2;
ds1 = histvalf_initvalf(caller, M, options);
failed_tests = my_assert(failed_tests, ds1.init == dates('2Y'), ...
@ -36,7 +36,7 @@ failed_tests = my_assert(failed_tests, ds1.init == dates('2Y'), ...
num_tests = num_tests + 1;
options = struct();
options.series = "ds";
options.series = 'ds';
options.first_obs = 2;
options.last_obs = 9;
ds1 = histvalf_initvalf(caller, M, options);
@ -47,7 +47,7 @@ failed_tests = my_assert(failed_tests, ds1.last == dates('9Y'), ...
num_tests = num_tests + 2;
options = struct();
options.series = "ds";
options.series = 'ds';
options.last_obs = 9;
ds1 = histvalf_initvalf(caller, M, options);
failed_tests = my_assert(failed_tests, ds1.init == dates('1Y'), ...
@ -57,7 +57,7 @@ failed_tests = my_assert(failed_tests, ds1.last == dates('9Y'), ...
num_tests = num_tests + 2;
options = struct();
options.series = "ds";
options.series = 'ds';
options.first_obs = 2;
options.last_obs = 9;
options.nobs = 8;
@ -69,7 +69,7 @@ failed_tests = my_assert(failed_tests, ds1.last == dates('9Y'), ...
num_tests = num_tests + 2;
options = struct();
options.series = "ds";
options.series = 'ds';
options.last_obs = 9;
options.nobs = 8;
ds1 = histvalf_initvalf(caller, M, options);
@ -80,7 +80,7 @@ failed_tests = my_assert(failed_tests, ds1.last == dates('9Y'), ...
num_tests = num_tests + 2;
options = struct();
options.series = "ds";
options.series = 'ds';
options.first_obs = 2;
options.last_obs = 9;
options.nobs = 7;
@ -98,7 +98,7 @@ end
num_tests = num_tests + 1;
options = struct();
options.series = "ds";
options.series = 'ds';
options.first_obs = 0;
try
@ -113,7 +113,7 @@ end
num_tests = num_tests + 1;
options = struct();
options.series = "ds";
options.series = 'ds';
options.last_obs = 11;
try

View File

@ -17,7 +17,11 @@ ylabels = char(percent,percent,percent,level);
figtitle = 'Simulated variables';
legendlist = cellstr(char('Piecewise Linear','Linear'));
options_.TeX=1;
if isoctave || ~matlab_ver_less_than('8.4')
% For some unknown reason, MATLAB R2014a crashes with TeX labels
% when -nodisplay is passed (as in the testsuite)
options_.TeX=1;
end
occbin_graph;
occbin_graph c_hat b_hat y_hat;