1function [o, id] = pop(o, a) % --*-- Unitary tests --*-- 2 3% Removes a variable from a dseries object. 4% 5% INPUTS 6% - o [dseries] T observations and N variables. 7% - a [string] Name of the variable to be removed. 8% 9% OUTPUTS 10% - o [dseries] T observations and N-1 variables. 11 12% Copyright (C) 2013-2017 Dynare Team 13% 14% This file is part of Dynare. 15% 16% Dynare is free software: you can redistribute it and/or modify 17% it under the terms of the GNU General Public License as published by 18% the Free Software Foundation, either version 3 of the License, or 19% (at your option) any later version. 20% 21% Dynare is distributed in the hope that it will be useful, 22% but WITHOUT ANY WARRANTY; without even the implied warranty of 23% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24% GNU General Public License for more details. 25% 26% You should have received a copy of the GNU General Public License 27% along with Dynare. If not, see <http://www.gnu.org/licenses/>. 28 29o = copy(o); 30 31if nargin<2 32 [o, id] = pop_(o); 33else 34 [o, id] = pop_(o, a); 35end 36 37%@test:1 38%$ % Define a datasets. 39%$ A = rand(10,3); 40%$ 41%$ % Define names 42%$ A_name = {'A1';'A2';'A3'}; 43%$ 44%$ t = zeros(4,1); 45%$ 46%$ % Instantiate a time series object. 47%$ try 48%$ ts1 = dseries(A,[],A_name,[]); 49%$ ts2 = ts1.pop('A2'); 50%$ t(1) = 1; 51%$ catch 52%$ t = 0; 53%$ end 54%$ 55%$ if length(t)>1 56%$ t(2) = dassert(ts2.vobs,2); 57%$ t(3) = dassert(ts2.nobs,10); 58%$ t(4) = dassert(ts2.data,[A(:,1), A(:,3)],1e-15); 59%$ t(5) = dassert(ts1.vobs,3); 60%$ if t(5) 61%$ t(6) = dassert(ts1.data,A,1e-15); 62%$ end 63%$ end 64%$ T = all(t); 65%@eof:1 66 67%@test:2 68%$ % Define a datasets. 69%$ A = rand(10,3); 70%$ 71%$ % Define names 72%$ A_name = {'A1';'A2';'A3'}; 73%$ 74%$ t = zeros(2,1); 75%$ 76%$ % Instantiate a time series object. 77%$ try 78%$ ts1 = dseries(A,[],A_name,[]); 79%$ [ts2,id] = pop(ts1,'A4'); 80%$ t(1) = 1; 81%$ catch 82%$ t = 0; 83%$ end 84%$ 85%$ if length(t)>1 86%$ t(2) = dassert(id,0); 87%$ t(2) = dassert(ts1,ts2); 88%$ end 89%$ T = all(t); 90%@eof:2 91