Commit 4ee3117f authored by Stéphane Adjemian's avatar Stéphane Adjemian

Added new member ops.

This member keeps track of the transformations and operations on the
variables. The name of the variables is now constant.
parent 531d78df
......@@ -66,10 +66,14 @@ o.abs_;
%$
%$ if t(1)
%$ t(2) = dassert(length(p.name), 2);
%$ t(3) = dassert(p.name{1},'abs(Variable_1)');
%$ t(4) = dassert(p.name{2},'abs(Variable_2)');
%$ t(5) = dassert(o.name{1},'Variable_1');
%$ t(6) = dassert(o.name{2},'Variable_2');
%$ t(3) = dassert(p.ops{1},'abs(Variable_1)');
%$ t(4) = dassert(p.ops{2},'abs(Variable_2)');
%$ t(5) = dassert(p.name{1},'Variable_1');
%$ t(6) = dassert(p.name{2},'Variable_2');
%$ t(7) = dassert(o.name{1},'Variable_1');
%$ t(8) = dassert(o.name{2},'Variable_2');
%$ t(9) = isempty(o.ops{1});
%$ t(10) = isempty(o.ops{2});
%$ end
%$
%$ T = all(t);
......@@ -96,13 +100,16 @@ o.abs_;
%$ t(2) = dassert(ts2.vobs,2);
%$ t(3) = dassert(ts2.nobs,10);
%$ t(4) = dassert(ts2.data,abs(A),1e-15);
%$ t(5) = dassert(ts2.name,{'abs(A1)';'abs(A2)'});
%$ t(6) = dassert(ts2.tex,{'|A_1|';'|A_2|'});
%$ t(7) = dassert(ts1.vobs, 2);
%$ t(8) = dassert(ts1.nobs, 10);
%$ t(9) = dassert(ts1.data, A, 1e-15);
%$ t(10) = dassert(ts1.name, {'A1';'A2'});
%$ t(11) = dassert(ts1.tex, {'A_1';'A_2'});
%$ t(5) = dassert(ts2.name,{'A1';'A2'});
%$ t(6) = dassert(ts2.ops,{'abs(A1)';'abs(A2)'});
%$ t(7) = dassert(ts2.tex,{'A_1';'A_2'});
%$ t(8) = dassert(ts1.vobs, 2);
%$ t(9) = dassert(ts1.nobs, 10);
%$ t(10) = dassert(ts1.data, A, 1e-15);
%$ t(11) = dassert(ts1.name, {'A1';'A2'});
%$ t(12) = dassert(ts1.tex, {'A_1';'A_2'});
%$ t(13) = isempty(ts1.ops{1});
%$ t(14) = isempty(ts1.ops{2});
%$ end
%$ T = all(t);
%@eof:3
......@@ -128,13 +135,16 @@ o.abs_;
%$ t(2) = dassert(ts2.vobs,2);
%$ t(3) = dassert(ts2.nobs,10);
%$ t(4) = dassert(ts2.data,abs(A),1e-15);
%$ t(5) = dassert(ts2.name,{'abs(A1)';'abs(A2)'});
%$ t(6) = dassert(ts2.tex,{'|A_1|';'|A_2|'});
%$ t(7) = dassert(ts1.vobs, 2);
%$ t(8) = dassert(ts1.nobs, 10);
%$ t(9) = dassert(ts1.data, A, 1e-15);
%$ t(10) = dassert(ts1.name, {'A1';'A2'});
%$ t(11) = dassert(ts1.tex, {'A_1';'A_2'});
%$ t(5) = dassert(ts2.name,{'A1';'A2'});
%$ t(6) = dassert(ts2.tex,{'A_1';'A_2'});
%$ t(7) = dassert(ts2.ops,{'abs(A1)';'abs(A2)'});
%$ t(8) = dassert(ts1.vobs, 2);
%$ t(9) = dassert(ts1.nobs, 10);
%$ t(10) = dassert(ts1.data, A, 1e-15);
%$ t(11) = dassert(ts1.name, {'A1';'A2'});
%$ t(12) = dassert(ts1.tex, {'A_1';'A_2'});
%$ t(13) = isempty(ts1.ops{1});
%$ t(14) = isempty(ts1.ops{2});
%$ end
%$ T = all(t);
%@eof:4
......@@ -26,8 +26,11 @@ function o = abs_(o) % --*-- Unitary tests --*--
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
for i=1:vobs(o)
o.name(i) = {['abs(' o.name{i} ')']};
o.tex(i) = {['|' o.tex{i} '|']};
if isempty(o.ops{i})
o.ops(i) = {['abs(' o.name{i} ')']};
else
o.ops(i) = {['abs(' o.ops{i} ')']};
end
end
o.data = abs(o.data);
......@@ -51,6 +54,12 @@ o.data = abs(o.data);
%$ t(2) = dassert(o.data, ones(10,2));
%$ t(3) = dassert(q.data, ones(10,2));
%$ t(4) = dassert(r.data, -ones(10, 2));
%$ t(5) = dassert(o.name{1}, 'Variable_1');
%$ t(6) = dassert(q.name{1}, 'Variable_1');
%$ t(7) = dassert(r.name{1}, 'Variable_1');
%$ t(8) = dassert(o.ops{1}, 'abs(Variable_1)');
%$ t(9) = dassert(q.ops{1}, 'abs(Variable_1)');
%$ t(10) = dassert(r.name{1}, 'Variable_1');
%$ end
%$
%$ T = all(t);
......@@ -73,12 +82,18 @@ o.data = abs(o.data);
%$
%$ if t(1)
%$ t(2) = dassert(length(o.name), 2);
%$ t(3) = dassert(o.name{1},'abs(Variable_1)');
%$ t(4) = dassert(o.name{2},'abs(Variable_2)');
%$ t(5) = dassert(q.name{1},'abs(Variable_1)');
%$ t(6) = dassert(q.name{2},'abs(Variable_2)');
%$ t(3) = dassert(o.name{1},'Variable_1');
%$ t(4) = dassert(o.name{2},'Variable_2');
%$ t(5) = dassert(q.name{1},'Variable_1');
%$ t(6) = dassert(q.name{2},'Variable_2');
%$ t(7) = dassert(r.name{1},'Variable_1');
%$ t(8) = dassert(r.name{2},'Variable_2');
%$ t(9) = dassert(o.ops{1},'abs(Variable_1)');
%$ t(10) = dassert(o.ops{2},'abs(Variable_2)');
%$ t(11) = dassert(q.ops{1},'abs(Variable_1)');
%$ t(12) = dassert(q.ops{2},'abs(Variable_2)');
%$ t(13) = isempty(r.ops{1});
%$ t(14) = isempty(r.ops{2});
%$ end
%$
%$ T = all(t);
......
......@@ -89,12 +89,16 @@ o.baxter_king_filter_(high_frequency, low_frequency, K);
%$ t(4) = dassert(ds.init.time, [1953, 1]);
%$ t(5) = dassert(ds.vobs, 1);
%$ t(6) = dassert(ds.nobs, 176);
%$ t(7) = dassert(ts.freq, 4);
%$ t(8) = dassert(ts.init.freq, 4);
%$ t(9) = dassert(ts.init.time, [1950, 1]);
%$ t(10) = dassert(ts.vobs, 1);
%$ t(11) = dassert(ts.nobs, length(y));
%$ t(12) = dassert(ts.data, y);
%$ t(7) = dassert(ds.name{1}, 'Variable_1');
%$ t(8) = dassert(ds.ops{1}, 'baxter_king_filter(Variable_1, 6, 32, 12)');
%$ t(9) = dassert(ts.freq, 4);
%$ t(10) = dassert(ts.name{1}, 'Variable_1');
%$ t(11) = dassert(ts.init.freq, 4);
%$ t(12) = dassert(ts.init.time, [1950, 1]);
%$ t(13) = dassert(ts.vobs, 1);
%$ t(14) = dassert(ts.nobs, length(y));
%$ t(15) = dassert(ts.data, y);
%$ t(16) = isempty(ts.ops{1});
%$ end
%$
%$ % Show results
......
......@@ -94,8 +94,19 @@ o.data = tmp(K+1:end-K,:);
init = firstdate(o)+K;
o.dates = init:init+(nobs(o)-1);
for i=1:vobs(o)
o.name(i) = {['baxter_king_filter(' o.name{i} ')']};
o.tex(i) = {['\text{baxter_king_filter}(' o.tex{i} ')']};
if isempty(o.ops{i})
o.ops(i) = {sprintf('baxter_king_filter(%s, %s, %s, %s)', ...
o.name{i}, ...
num2str(high_frequency), ...
num2str(low_frequency), ...
num2str(K))};
else
o.ops(i) = {sprintf('baxter_king_filter(%s, %s, %s, %s)', ...
o.ops{i}, ...
num2str(high_frequency), ...
num2str(low_frequency), ...
num2str(K))};
end
end
......@@ -116,7 +127,7 @@ end
%$ % Test the routine.
%$ try
%$ ts = dseries(y,'1950Q1');
%$ ts = ts.baxter_king_filter_();
%$ ts.baxter_king_filter_();
%$ xx = dseries(x,'1950Q1');
%$ t(1) = 1;
%$ catch
......@@ -129,6 +140,8 @@ end
%$ t(4) = dassert(ts.init.time,[1953, 1]);
%$ t(5) = dassert(ts.vobs,1);
%$ t(6) = dassert(ts.nobs,176);
%$ t(7) = dassert(ts.name{1},'Variable_1');
%$ t(8) = dassert(ts.ops{1},'baxter_king_filter(Variable_1, 6, 32, 12)');
%$ end
%$
%$ % Show results
......
......@@ -49,6 +49,10 @@ o.center_(geometric);
%$ if t(1)
%$ t(2) = all(all(abs(ds.data-ones(10,2))<1e-12));
%$ t(3) = all(all(abs(ts.data-A)<1e-12));
%$ t(4) = dassert(ds.ops{1}, 'center(Variable_1, 1)');
%$ t(5) = dassert(ds.name{1}, 'Variable_1');
%$ t(6) = isempty(ts.ops{1});
%$ t(7) = dassert(ds.name{1}, 'Variable_1');
%$ end
%$ T = all(t);
%@eof:1
......@@ -38,6 +38,14 @@ else
o.data = bsxfun(@minus, o.data, m);
end
for i=1:o.vobs
if isempty(o.ops{i})
o.ops(i) = {sprintf('center(%s, %s)', o.name{i}, num2str(geometric))};
else
o.ops(i) = {sprintf('center(%s, %s)', o.ops{i}, num2str(geometric))};
end
end
%@test:1
%$ % Define a dataset.
%$ A = repmat([1.005, 1.05], 10, 1);
......@@ -53,6 +61,8 @@ end
%$
%$ if t(1)
%$ t(2) = all(all(abs(ts.data-ones(10,2))<1e-12));
%$ t(3) = dassert(ts.ops{1}, 'center(Variable_1, 1)');
%$ t(4) = dassert(ts.name{1}, 'Variable_1');
%$ end
%$ T = all(t);
%@eof:1
......@@ -37,6 +37,23 @@ o.data = [o.data; bsxfun(@times,CumulatedGrowthFactors, o.data(end,:))];
o.dates = firstdate(o):firstdate(o)+nobs(o);
for i=1:o.vobs
if isempty(o.ops{i})
if noinputname
o.ops(i) = {sprintf('chain(%s, %s)', o.name{i}, p.name{i})};
else
o.ops(i) = {sprintf('chain(%s, %s.%s)', o.name{i}, inputname(2), p.name{i})};
end
else
if noinputname
o.ops(i) = {sprintf('chain(%s, %s)', o.ops{i}, p.name{i})};
else
o.ops(i) = {sprintf('chain(%s, %s.%s)', o.ops{i}, inputname(2), p.name{i})};
end
end
end
%@test:1
%$ try
%$ ts = dseries([1; 2; 3; 4],dates('1950Q1')) ;
......
......@@ -28,6 +28,7 @@ p.data = o.data;
p.name = o.name;
p.tex = o.tex;
p.dates = o.dates;
p.ops = o.ops;
%@test:1
%$ % Define a dates object
......
......@@ -59,9 +59,11 @@ end
%$
%$ if t(1)
%$ t(2) = isequal(ds.data, cumprod(A));
%$ t(3) = isequal(ds.name{1}, 'cumprod(A1)');
%$ t(4) = isequal(ts.data, A);
%$ t(5) = isequal(ts.name{1}, 'A1');
%$ t(3) = isequal(ds.name{1}, 'A1');
%$ t(4) = isequal(ds.ops{1}, 'cumprod(A1)');
%$ t(5) = isequal(ts.data, A);
%$ t(6) = isequal(ts.name{1}, 'A1');
%$ t(7) = isempty(ts.ops{1});
%$ end
%$
%$ T = all(t);
......
......@@ -61,10 +61,12 @@ switch nargin
o.data = cumprodnan(o.data);
end
end
% Change the name of the variables
for i=1:vobs(o)
o.name(i) = {['cumprod(' o.name{i} ')']};
o.tex(i) = {['\prod_t ' o.tex{i}]};
if isempty(o.ops{i})
o.ops(i) = {['cumprod(' o.name{i} ')']};
else
o.ops(i) = {['cumprod(' o.ops{i} ')']};
end
end
case 2
if isdseries(varargin{2})
......@@ -146,7 +148,8 @@ end
%$
%$ if t(1)
%$ t(2) = isequal(ts.data, cumprod(A));
%$ t(3) = isequal(ts.name{1}, 'cumprod(A1)');
%$ t(3) = isequal(ts.name{1}, 'A1');
%$ t(4) = isequal(ts.ops{1}, 'cumprod(A1)');
%$ end
%$
%$ T = all(t);
......@@ -171,8 +174,9 @@ end
%$ end
%$
%$ if t(1)
%$ t(2) = isequal(ts.data,cumprod(A));
%$ t(3) = isequal(ts.name{1},'cumprod(A1)');
%$ t(2) = isequal(ts.data, cumprod(A));
%$ t(3) = isequal(ts.name{1},'A1');
%$ t(4) = isequal(ts.ops{1}, 'cumprod(A1)');
%$ end
%$
%$ T = all(t);
......
......@@ -61,10 +61,12 @@ switch nargin
o.data = cumsumnan(o.data);
end
end
% Change the name of the variables
for i=1:vobs(o)
o.name(i) = {['cumsum(' o.name{i} ')']};
o.tex(i) = {['\sum_t ' o.tex{i}]};
if isempty(o.ops{i})
o.ops(i) = {['cumsum(' o.name{i} ')']};
else
o.ops(i) = {['cumsum(' o.ops{i} ')']};
end
end
case 2
if isdseries(varargin{2})
......
......@@ -52,6 +52,14 @@ else
error('dseries::detrend: Second argument must be a positive integer scalar!')
end
for i=1:vobs(o)
if isempty(o.ops{i})
o.ops(i) = {sprintf('detrend(%s, %s)', o.name{i}, num2str(model))};
else
o.ops(i) = {sprintf('detrend(%s, %s)', o.ops{i}, num2str(model))};
end
end
%@test:1
%$ % Define a dataset.
%$ a = dseries(randn(1000,3));
......
......@@ -22,6 +22,7 @@ properties
name = {}; % Names of the variables.
tex = {}; % TeX names of the variables.
dates = dates(); % Dates associated to the observations.
ops = {}; % History of operations on the variables.
end
methods
......@@ -52,6 +53,7 @@ methods
o.name = {};
o.tex = {};
o.dates = dates();
o.ops = {};
return
case 1
if isdates(varargin{1})
......@@ -64,6 +66,7 @@ methods
o.name = {};
o.tex = {};
o.dates = varargin{1};
o.ops = {};
otherwise
error('dseries:WrongInputArguments', 'Input (identified as a dates object) must have a unique element!');
end
......@@ -74,6 +77,7 @@ methods
o.name = varlist;
o.dates = init:init+(nobs(o)-1);
o.tex = tex;
o.ops = cell(length(o.name), 1);
elseif ~isoctave() && istable(varargin{1})
% It is assumed that the dates are in the first column.
thistable = varargin{1};
......@@ -81,11 +85,13 @@ methods
o.tex = name2tex(o.name);
o.data = varargin{1}{:,2:end};
o.dates = dates(varargin{1}{1,1}{1})+(0:size(varargin{1}, 1)-1);
o.ops = cell(length(o.name), 1);
elseif isnumeric(varargin{1}) && isequal(ndims(varargin{1}),2)
o.data = varargin{1};
o.name = default_name(vobs(o));
o.tex = name2tex(o.name);
o.dates = dates(1,1):dates(1,1)+(nobs(o)-1);
o.ops = cell(length(o.name), 1);
end
case {2,3,4}
if isequal(nargin,2) && ischar(varargin{1}) && isdates(varargin{2})
......@@ -97,6 +103,7 @@ methods
o.name = varlist;
o.dates = varargin{2}:varargin{2}+(nobs(o)-1);
o.tex = tex;
o.ops = cell(length(o.name), 1);
return
end
if isequal(nargin,2) && ischar(varargin{1}) && ischar(varargin{2}) && isdate(varargin{2})
......@@ -108,6 +115,7 @@ methods
o.name = varlist;
o.dates = dates(varargin{2}):dates(varargin{2})+(nobs(o)-1);
o.tex = tex;
o.ops = cell(length(o.name), 1);
return
end
a = varargin{1};
......@@ -168,6 +176,7 @@ methods
else
o.name = default_name(vobs(o));
end
o.ops = cell(length(o.name), 1);
if ~isempty(d)
if vobs(o)==length(d)
for i=1:vobs(o)
......@@ -222,7 +231,7 @@ end % classdef
%@eof:2
%@test:3
%$ t = zeros(6,1);
%$ t = zeros(8, 1);
%$
%$ try
%$ [strfile, status] = urlwrite('http://www.dynare.org/Datasets/dseries/dynseries_test_data.m','dynseries_test_data.m');
......@@ -242,13 +251,15 @@ end % classdef
%$ t(4) = dassert(ts.init.time,[1994, 3]);
%$ t(5) = dassert(ts.vobs,2);
%$ t(6) = dassert(ts.nobs,100);
%$ t(7) = dassert(length(ts.ops), 2);
%$ t(8) = isempty(ts.ops{1}) && isempty(ts.ops{2});
%$ end
%$
%$ T = all(t);
%@eof:3
%@test:4
%$ t = zeros(6,1);
%$ t = zeros(8, 1);
%$
%$ try
%$ [strfile, status] = urlwrite('http://www.dynare.org/Datasets/dseries/dynseries_test_data.mat','dynseries_test_data.mat');
......@@ -268,13 +279,15 @@ end % classdef
%$ t(4) = dassert(ts.init.time,[1994, 3]);
%$ t(5) = dassert(ts.vobs,2);
%$ t(6) = dassert(ts.nobs,100);
%$ t(7) = dassert(length(ts.ops), 2);
%$ t(8) = isempty(ts.ops{1}) && isempty(ts.ops{2});
%$ end
%$
%$ T = all(t);
%@eof:4
%@test:5
%$ t = zeros(8,1);
%$ t = zeros(10, 1);
%$
%$ try
%$ [strfile, status] = urlwrite('http://www.dynare.org/Datasets/dseries/dynseries_test_data.csv','dynseries_test_data.csv');
......@@ -296,13 +309,15 @@ end % classdef
%$ t(6) = dassert(ts.nobs,4);
%$ t(7) = dassert(ts.name,{'azert';'yuiop';'qsdfg';'jklm'});
%$ t(8) = dassert(ts.tex,{'azert';'yuiop';'qsdfg';'jklm'});
%$ t(9) = dassert(length(ts.ops), 4);
%$ t(10) = isempty(ts.ops{1}) && isempty(ts.ops{2}) && isempty(ts.ops{3}) && isempty(ts.ops{4}) ;
%$ end
%$
%$ T = all(t);
%@eof:5
%@test:6
%$ t = zeros(8,1);
%$ t = zeros(10, 1);
%$
%$ try
%$ ts = dseries(transpose(1:5),[]);
......@@ -319,13 +334,15 @@ end % classdef
%$ t(6) = dassert(ts.nobs,5);
%$ t(7) = dassert(ts.name,{'Variable_1'});
%$ t(8) = dassert(ts.tex,{'Variable\\_1'});
%$ t(9) = dassert(length(ts.ops), 1);
%$ t(10) = isempty(ts.ops{1});
%$ end
%$
%$ T = all(t);
%@eof:6
%@test:7
%$ t = zeros(8,1);
%$ t = zeros(10, 1);
%$
%$ try
%$ ts = dseries(transpose(1:5),'1950Q1');
......@@ -342,13 +359,15 @@ end % classdef
%$ t(6) = dassert(ts.nobs,5);
%$ t(7) = dassert(ts.name,{'Variable_1'});
%$ t(8) = dassert(ts.tex,{'Variable\\_1'});
%$ t(9) = dassert(length(ts.ops), 1);
%$ t(10) = isempty(ts.ops{1});
%$ end
%$
%$ T = all(t);
%@eof:7
%@test:8
%$ t = zeros(8,1);
%$ t = zeros(10, 1);
%$
%$ try
%$ ts = dseries([transpose(1:5), transpose(6:10)],'1950q1',{'Output'; 'Consumption'}, {'Y_t'; 'C_t'});
......@@ -365,6 +384,8 @@ end % classdef
%$ t(6) = dassert(ts.nobs,5);
%$ t(7) = dassert(ts.name,{'Output'; 'Consumption'});
%$ t(8) = dassert(ts.tex,{'Y_t'; 'C_t'});
%$ t(9) = dassert(length(ts.ops), 2);
%$ t(10) = isempty(ts.ops{1}) && isempty(ts.ops{2});
%$ end
%$
%$ T = all(t);
......@@ -400,6 +421,8 @@ end % classdef
%$ t(6) = dassert(ts.nobs,5);
%$ t(7) = dassert(ts.name,{'GDP';'Consumption';'CPI'});
%$ t(8) = dassert(ts.tex,{'GDP';'Consumption';'CPI'});
%$ t(9) = dassert(length(ts.ops), 3);
%$ t(10) = isempty(ts.ops{1}) && isempty(ts.ops{2}) && isempty(ts.ops{3});
%$ end
%$
%$ T = all(t);
......@@ -435,6 +458,8 @@ end % classdef
%$ t(6) = dassert(ts.nobs,5);
%$ t(7) = dassert(ts.name,{'Variable_1';'Variable_2';'Variable_3'});
%$ t(8) = dassert(ts.tex,{'Variable\\_1';'Variable\\_2';'Variable\\_3'});
%$ t(9) = dassert(length(ts.ops), 3);
%$ t(10) = isempty(ts.ops{1}) && isempty(ts.ops{2}) && isempty(ts.ops{3});
%$ end
%$
%$ T = all(t);
......@@ -470,6 +495,8 @@ end % classdef
%$ t(6) = dassert(ts.nobs,5);
%$ t(7) = dassert(ts.name,{'Variable_1';'Variable_2';'Variable_3'});
%$ t(8) = dassert(ts.tex,{'Variable\\_1';'Variable\\_2';'Variable\\_3'});
%$ t(9) = dassert(length(ts.ops), 3);
%$ t(10) = isempty(ts.ops{1}) && isempty(ts.ops{2}) && isempty(ts.ops{3});
%$ end
%$
%$ T = all(t);
......@@ -505,13 +532,15 @@ end % classdef
%$ t(6) = dassert(ts.nobs,5);
%$ t(7) = dassert(ts.name,{'GDP';'Consumption';'CPI'});
%$ t(8) = dassert(ts.tex,{'GDP';'Consumption';'CPI'});
%$ t(9) = dassert(length(ts.ops), 3);
%$ t(10) = isempty(ts.ops{1}) && isempty(ts.ops{2}) && isempty(ts.ops{3});
%$ end
%$
%$ T = all(t);
%@eof:12
%@test:13
%$ t = zeros(6,1);
%$ t = zeros(8, 1);
%$
%$ try
%$ ts = dseries(transpose(1:4),dates('1990Q1'):dates('1990Q4'));
......@@ -526,13 +555,15 @@ end % classdef
%$ t(4) = dassert(ts.init.time,[1990, 1]);
%$ t(5) = dassert(ts.vobs,1);
%$ t(6) = dassert(ts.nobs,4);
%$ t(7) = dassert(length(ts.ops), 1);
%$ t(8) = isempty(ts.ops{1});
%$ end
%$
%$ T = all(t);
%@eof:13
%@test:14
%$ t = zeros(7,1);
%$ t = zeros(9, 1);
%$
%$ try
%$ ts = dseries([1, 2],dates('1990Q1'):dates('1990Q4'));
......@@ -548,6 +579,8 @@ end % classdef
%$ t(5) = dassert(ts.vobs,2);
%$ t(6) = dassert(ts.nobs,4);
%$ t(7) = dassert(ts.data, [ones(4,1), 2*ones(4,1)]);
%$ t(8) = dassert(length(ts.ops), 2);
%$ t(9) = isempty(ts.ops{1}) && isempty(ts.ops{2});
%$ end
%$
%$ T = all(t);
......
......@@ -66,10 +66,14 @@ o.exp_();
%$
%$ if t(1)
%$ t(2) = dassert(length(p.name), 2);
%$ t(3) = dassert(p.name{1},'exp(Variable_1)');
%$ t(4) = dassert(p.name{2},'exp(Variable_2)');
%$ t(3) = dassert(p.name{1},'Variable_1');
%$ t(4) = dassert(p.name{2},'Variable_2');
%$ t(5) = dassert(o.name{1},'Variable_1');
%$ t(6) = dassert(o.name{2},'Variable_2');
%$ t(7) = dassert(p.ops{1},'exp(Variable_1)');
%$ t(8) = dassert(p.ops{2},'exp(Variable_2)');
%$ t(9) = isempty(o.ops{1});
%$ t(10) = isempty(o.ops{2});
%$ end
%$
%$ T = all(t);
......
......@@ -28,8 +28,11 @@ function o = exp_(o) % --*-- Unitary tests --*--
o.data = exp(o.data);
for i=1:vobs(o)
o.name(i) = {['exp(' o.name{i} ')']};
o.tex(i) = {['\exp(' o.tex{i} ')']};
if isempty(o.ops{i})
o.ops(i) = {['exp(' o.name{i} ')']};
else
o.ops(i) = {['exp(' o.ops{i} ')'];}
end
end
%@test:1
......@@ -73,12 +76,18 @@ end
%$
%$ if t(1)
%$ t(2) = dassert(length(o.name), 2);
%$ t(3) = dassert(o.name{1},'exp(Variable_1)');
%$ t(4) = dassert(o.name{2},'exp(Variable_2)');
%$ t(5) = dassert(q.name{1},'exp(Variable_1)');
%$ t(6) = dassert(q.name{2},'exp(Variable_2)');
%$ t(7) = dassert(r.name{1},'Variable_1');
%$ t(8) = dassert(r.name{2},'Variable_2');
%$ t(3) = dassert(o.name{1},'Variable_1');
%$ t(4) = dassert(o.name{2},'Variable_2');
%$ t(5) = dassert(q.name{1},'Variable_1');
%$ t(6) = dassert(q.name{2},'Variable_2');
%$ t(7) = dassert(o.ops{1},'exp(Variable_1)');
%$ t(8) = dassert(o.ops{2},'exp(Variable_2)');
%$ t(9) = dassert(q.ops{1},'exp(Variable_1)');
%$ t(10) = dassert(q.ops{2},'exp(Variable_2)');
%$ t(11) = dassert(r.name{1},'Variable_1');
%$ t(12) = dassert(r.name{2},'Variable_2');
%$ t(13) = isempty(r.ops{1});
%$ t(14) = isempty(r.ops{2});
%$ end
%$
%$ T = all(t);
......
......@@ -97,7 +97,7 @@ p.data = o.data(:,idVariableName);
p.dates = o.dates;
p.name = o.name(idVariableName);
p.tex = o.tex(idVariableName);
p.ops = o.ops(idVariableName);
%@test:1
%$ % Define a data set.
......
......@@ -75,6 +75,7 @@ d_init_flag = 0;
if ~isequal(firstdate(b),firstdate(c))
d_init_flag = 1;
end
a.ops = vertcat(b.ops,c.ops);
a.name = vertcat(b.name,c.name);
a.tex = vertcat(b.tex,c.tex);
if ~( d_nobs_flag(1) || d_init_flag(1) )
......
......@@ -34,14 +34,25 @@ else
lambda = [];
end
for i=1:vobs(o)
o.name(i) = {['hpcycle(' o.name{i} ')']};
o.tex(i) = {['\text{hpcycle}(' o.tex{i} ')']};
end
[junk, data] = sample_hp_filter(o.data,lambda);
o.data = data;
for i=1:vobs(o)
if isempty(o.ops{i})
if isempty(lambda)
o.ops(i) = {sprintf('hpcycle(%s, [])', o.name{i})};
else
o.ops(i) = {sprintf('hpcycle(%s, %s)', o.name{i}, num2str(lambda))};
end
else
if isempty(lambda)
o.ops(i) = {sprintf('hpcycle(%s, [])', o.ops{i})};
else
o.ops(i) = {sprintf('hpcycle(%s, %s)', o.ops{i}, num2str(lambda))};
end
end
end
%@test:1
%$ plot_flag = false;
%$
......
......@@ -34,12 +34,24 @@ else
lambda = [];
end
o.data = sample_hp_filter(o.data, lambda);
for i=1:vobs(o)
o.name(i) = {['hptrend(' o.name{i} ')']};
o.tex(i) = {['\text{hptrend}(' o.tex{i} ')']};
if isempty(o.ops{i})
if isempty(lambda)
o.ops(i) = {sprintf('hptrend(%s, [])', o.name{i})};
else
o.ops(i) = {sprintf('hptrend(%s, %s)', o.name{i}, num2str(lambda))};
end
else
if isempty(lambda)
o.ops(i) = {sprintf('hptrend(%s, [])', o.name{i})};
else
o.ops(i) = {sprintf('hptrend(%s, %s)', o.name{i}, num2str(lambda))};
end
end
end
o.data = sample_hp_filter(o.data, lambda);
%@test:1
%$ plot_flag = 0;
......
......@@ -30,11 +30,19 @@ function o = insert(o, p, id) % --*-- Unitary tests --*--
[n, message] = common_strings_in_cell_arrays(o.name, p.name);
if n
error(['dseries::insert: Variable(s) ' message ' already exist in ''' inputname(1) '''!'])
if isempty(inputname(1))
error(['dseries::insert: Variable(s) ' message ' already exist in dseries object!'])
else
error(['dseries::insert: Variable(s) ' message ' already exist in ''' inputname(1) '''!'])
end
end
if ~isequal(frequency(o),frequency(p))
error(['dseries::insert: ''' inputname(1) ''' and ''' inputname(2) ''' dseries objects must have common frequencies!'])
if isempty(inputname(1))
error(['dseries::insert: dseries objects must have common frequencies!'])
else
error(['dseries::insert: ''' inputname(1) ''' and ''' inputname(2) ''' dseries objects must have common frequencies!'])
end
end
% Keep the second input argument constant.
......@@ -49,12 +57,14 @@ if n>1
p.data = p.data(:,jd);
p.name = p.name(jd);
p.tex = p.tex(jd);
p.ops = p.ops(jd);
end
for i=1:n
o.data = insert_column_vector_in_a_matrix(o.data, p.data(:,i),id(i));
o.name = insert_object_in_a_one_dimensional_cell_array(o.name, p.name{i}, id(i));
o.tex = insert_object_in_a_one_dimensional_cell_array(o.tex, p.tex{i}, id(i));
o.ops = insert_object_in_a_one_dimensional_cell_array(o.ops, p.ops{i}, id(i));
id = id+1;
end