From ec5468c431181bc77c577ee6b383433636901f48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Fri, 15 Apr 2022 14:32:54 +0200 Subject: [PATCH] Octave 7 compatibility fix: suppress spurious warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this version of Octave, “warning on” really enables all warnings (while this was not the case in Octave 6, suprisingly; I think this used to be different with even older Octave releases). We therefore need to explicitly disable the Octave:array-as-logical warnings, that is triggered by some internal Octave functions. We also need to be careful to call “warning_config” instead of “warning on” when restoring warnings to their default state. --- matlab/+mom/run.m | 8 ++------ matlab/+occbin/kalman_update_algo_1.m | 6 +++--- matlab/WriteShockDecomp2Excel.m | 4 ++-- matlab/dynare_identification.m | 8 ++------ matlab/modules/reporting | 2 +- matlab/warning_config.m | 1 + 6 files changed, 11 insertions(+), 18 deletions(-) diff --git a/matlab/+mom/run.m b/matlab/+mom/run.m index d01fb51025..ccbb4bb3d5 100644 --- a/matlab/+mom/run.m +++ b/matlab/+mom/run.m @@ -63,7 +63,7 @@ function [oo_, options_mom_, M_] = run(bayestopt_, options_, oo_, estim_params_, % o set_all_parameters.m % o test_for_deep_parameters_calibration.m % ========================================================================= -% Copyright © 2020-2021 Dynare Team +% Copyright © 2020-2022 Dynare Team % % This file is part of Dynare. % @@ -1018,11 +1018,7 @@ fprintf('\n==== Method of Moments Estimation (%s) Completed ====\n\n',options_mo % Step 9: Clean up % ------------------------------------------------------------------------- %reset warning state -if isoctave - warning('on') -else - warning on -end +warning_config; if isoctave && isfield(options_, 'prior_restrictions') && ... isfield(options_.prior_restrictions, 'routine') diff --git a/matlab/+occbin/kalman_update_algo_1.m b/matlab/+occbin/kalman_update_algo_1.m index 46bde0664d..be990666c2 100644 --- a/matlab/+occbin/kalman_update_algo_1.m +++ b/matlab/+occbin/kalman_update_algo_1.m @@ -42,7 +42,7 @@ function [a, a1, P, P1, v, T, R, C, regimes_, error_flag, M_, lik, etahat] = kal % Philipp Pfeiffer, Marco Ratto (2021), Efficient and robust inference of models with occasionally binding % constraints, Working Papers 2021-03, Joint Research Centre, European Commission -% Copyright © 2021 Dynare Team +% Copyright © 2021-2022 Dynare Team % % This file is part of Dynare. % @@ -323,7 +323,7 @@ P(:,:,2) = T(:,:,2)*P(:,:,1)*transpose(T(:,:,2))+QQ; regimes_=regimes_(1:3); etahat=etahat(:,2); -warning on +warning_config; end function [a, a1, P, P1, v, alphahat, etahat, lik] = occbin_kalman_update0(a,a1,P,P1,data_index,Z,v,Y,H,QQQ,TT,RR,CC,iF,L,mm, rescale_prediction_error_covariance, IF_likelihood) @@ -424,5 +424,5 @@ while t > 1 end end -warning on +warning_config; end diff --git a/matlab/WriteShockDecomp2Excel.m b/matlab/WriteShockDecomp2Excel.m index b380278149..8b14aaeb08 100644 --- a/matlab/WriteShockDecomp2Excel.m +++ b/matlab/WriteShockDecomp2Excel.m @@ -11,7 +11,7 @@ function WriteShockDecomp2Excel(z,shock_names,endo_names,i_var,initial_date,Dyna % DynareModel [structure] Dynare model structure % DynareOptions [structure] Dynare options structure -% Copyright © 2016-2021 Dynare Team +% Copyright © 2016-2022 Dynare Team % % This file is part of Dynare. % @@ -124,7 +124,7 @@ for j=1:nvar else writetable(cell2table(d0), [OutputDirectoryName,filesep,DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1 '.xls'], 'Sheet', endo_names{i_var(j)},'WriteVariableNames',false); end - warning on + warning_config; clear d0 diff --git a/matlab/dynare_identification.m b/matlab/dynare_identification.m index a14402371f..8dcf14da1e 100644 --- a/matlab/dynare_identification.m +++ b/matlab/dynare_identification.m @@ -46,7 +46,7 @@ function [pdraws, STO_REDUCEDFORM, STO_MOMENTS, STO_DYNAMIC, STO_si_dDYNAMIC, ST % * skipline % * vnorm % ========================================================================= -% Copyright © 2010-2021 Dynare Team +% Copyright © 2010-2022 Dynare Team % % This file is part of Dynare. % @@ -968,11 +968,7 @@ if SampleSize > 1 end %reset warning state -if isoctave - warning('on') -else - warning on -end +warning_config; fprintf('\n==== Identification analysis completed ====\n\n') diff --git a/matlab/modules/reporting b/matlab/modules/reporting index 4fb36e8bcc..43d4bafa36 160000 --- a/matlab/modules/reporting +++ b/matlab/modules/reporting @@ -1 +1 @@ -Subproject commit 4fb36e8bccd623ed892778dba8a765b1a79a569a +Subproject commit 43d4bafa36380e99f6ae4b3d3a3160fb9f1699c0 diff --git a/matlab/warning_config.m b/matlab/warning_config.m index f867ed2c11..8f403fbef4 100644 --- a/matlab/warning_config.m +++ b/matlab/warning_config.m @@ -41,6 +41,7 @@ if isoctave warning('off', 'Octave:num-to-str'); warning('off', 'Octave:resize-on-range-error'); warning('off', 'Octave:str-to-num'); + warning('off', 'Octave:array-as-logical'); warning('off', 'Octave:array-to-scalar'); warning('off', 'Octave:array-to-vector'); warning('off', 'Octave:mixed-string-concat'); -- GitLab