Skip to content
Snippets Groups Projects
Commit 78a89f87 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Handle the case where the variable to be removed does not exist. Added a unitary test.

parent 9b4b7c46
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,10 @@ function [ts,id] = pop(ts,a)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
id = strmatch(a,ts.name,'exact');
if isempty(id)
id = 0;
return
end
ts.vobs = ts.vobs-1;
ts.data(:,id) = [];
ts.name(id) = [];
......@@ -75,3 +79,28 @@ ts.tex(id) = [];
%$ end
%$ T = all(t);
%@eof:1
%@test:1
%$ % Define a datasets.
%$ A = rand(10,3);
%$
%$ % Define names
%$ A_name = {'A1';'A2';'A3'};
%$
%$ t = zeros(2,1);
%$
%$ % Instantiate a time series object.
%$ try
%$ ts1 = dynSeries(A,[],A_name,[]);
%$ [ts2,id] = pop(ts1,'A4');
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if length(t)>1
%$ t(2) = dyn_assert(id,0);
%$ t(2) = dyn_assert(ts1==ts2,1);
%$ end
%$ T = all(t);
%@eof:1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment