Commit fbb38d55 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Renamed time member as dates (in dseries class) to avoid confusion with dates class' time member.

parent 805d4dda
......@@ -86,7 +86,7 @@ elseif last_a<last_b
a.nobs = a.nobs+n;
end
a.time = a.init:a.init+(a.nobs-1);
a.dates = a.init:a.init+(a.nobs-1);
%@test:1
%$ % Define a datasets.
......
......@@ -95,7 +95,7 @@ end
ts.data = tmp(K+1:end-K,:);
ts.nobs = ts.nobs-2*K;
ts.init = ts.init+K;
ts.time = ts.init:ts.init+(ts.nobs-1);
ts.dates = ts.init:ts.init+(ts.nobs-1);
%@test:1
%$ plot_flag = 0;
......@@ -131,7 +131,7 @@ ts.time = ts.init:ts.init+(ts.nobs-1);
%$
%$ % Show results
%$ if plot_flag
%$ plot(xx(ts.time).data,'-k');
%$ plot(xx(ts.dates).data,'-k');
%$ hold on
%$ plot(ts.data,'--r');
%$ hold off
......
......@@ -69,7 +69,7 @@ if ~isequal(numel(unique(A.name)),numel(A.name));
return
end
if ~isequal(numel(unique(A.tex)),numel(A.tex));
if ~isequa(numel(unique(A.tex)),numel(A.tex));
error_flag = 1;
if nargout>1
message = ['dseries: The variable tex names in dseries object ''' inputname(1) ''' are not unique!']:
......@@ -77,7 +77,7 @@ if ~isequal(numel(unique(A.tex)),numel(A.tex));
return
end
if ~isequal(A.time,A.init:A.init+A.nobs)
if ~isequal(A.dates,A.init:A.init+A.nobs)
error_flag = 1;
if nargout>1
message = ['dseries: Wrong definition of the time member in dseries object ''' inputname(1) '''!']:
......
......@@ -64,7 +64,7 @@ switch nargin
B.data = bsxfun(@plus,B.data,varargin{2}.data);
elseif isdates(varargin{2})
B = cumsum(varargin{1});
t = find(B.time==varargin{2});
t = find(B.dates==varargin{2});
if isempty(t)
if varargin{2}==(B.init-1)
return
......@@ -93,7 +93,7 @@ switch nargin
error('dseries::cumsum: Third input argument must be a dseries object with only one observation!')
end
B = cumsum(varargin{1});
t = find(B.time==varargin{2});
t = find(B.dates==varargin{2});
if isempty(t)
if varargin{2}==(B.init-1)
B.data = bsxfun(@plus,B.data,varargin{3}.data);
......
......@@ -23,7 +23,7 @@ separator = repmat(' | ',A.nobs+1,1);
vspace = ' ';
TABLE = ' ';
for t=1:A.nobs
TABLE = char(TABLE, format(A.time(t)));
TABLE = char(TABLE, format(A.dates(t)));
end
for i = 1:A.vobs
TABLE = horzcat(TABLE,separator);
......
......@@ -24,7 +24,7 @@ TABLE = ' ';
if A.nobs<=40
separator = repmat(' | ',A.nobs+1,1);
for t=1:A.nobs
TABLE = char(TABLE, date2string(A.time(t)));
TABLE = char(TABLE, date2string(A.dates(t)));
end
for i = 1:A.vobs
TABLE = horzcat(TABLE,separator);
......@@ -38,11 +38,11 @@ else
n = 10;
separator = repmat(' | ',2*n+3,1);
for t=1:n
TABLE = char(TABLE, date2string(A.time(t)));
TABLE = char(TABLE, date2string(A.dates(t)));
end
TABLE = char(TABLE,vspace);
for t = A.nobs-n:A.nobs
TABLE = char(TABLE, date2string(A.time(t)));
TABLE = char(TABLE, date2string(A.dates(t)));
end
for i=1:A.vobs
TABLE = horzcat(TABLE,separator);
......
......@@ -78,14 +78,14 @@ function ts = dseries(varargin) % --*-- Unitary tests --*--
ts = struct;
ts.data = [];
ts.nobs = 0;
ts.vobs = 0;
ts.name = {};
ts.tex = {};
ts.freq = [];
ts.init = dates();
ts.time = dates();
ts.data = [];
ts.nobs = 0;
ts.vobs = 0;
ts.name = {};
ts.tex = {};
ts.freq = [];
ts.init = dates();
ts.dates = dates();
ts = class(ts,'dseries');
......@@ -94,16 +94,16 @@ switch nargin
% Create an empty dseries object.
return
case 1
if isa(varargin{1},'dates') && isequal(length(varargin{1}),1)
if isa(varargin{1},'dates')
switch length(varargin{1})
case 0
error(['dseries::dseries: ' inputname(1) ' (identified as a dates object) must be non empty!'])
error(['dseries::dseries: Input ' inputname(1) ' (identified as a dates object) must be non empty!'])
case 1
% Create an empty dseries object with an initial date.
ts.init = varargin{1};
ts.freq = varargin{1}.freq;
otherwise
error(['dseries::dseries: ' inputname(1) ' (identified as a dates object) must have only one element!'])
error(['dseries::dseries: Input ' inputname(1) ' (identified as a dates object) must have only one element!'])
end
return
elseif ischar(varargin{1})
......@@ -214,7 +214,7 @@ switch nargin
error('dseries::dseries: Can''t instantiate the class, wrong calling sequence!')
end
ts.time = ts.init:ts.init+(ts.nobs-1);
ts.dates = ts.init:ts.init+(ts.nobs-1);
%@test:1
%$ % Test if we can instantiate an empty dseries object.
......
......@@ -122,7 +122,7 @@ for i = 1:length(idVariableName)
end
A.data = B.data(:,idVariableName);
A.time = B.time;
A.dates = B.dates;
A.init = B.init;
A.freq = B.freq;
A.nobs = B.nobs;
......
......@@ -76,7 +76,7 @@ function a = concatenate(b,c)
if ~( d_nobs_flag(1) || d_init_flag(1) )
a.init = b.init;
a.data = [b.data,c.data];
a.time = b.time;
a.dates = b.dates;
else
if b.init<=c.init
a.init = b.init;
......@@ -96,7 +96,7 @@ function a = concatenate(b,c)
c.data = [c.data; NaN(b_last_date-c_last_date,c.vobs)];
end
a.data = [b.data, c.data];
a.time = unique([b.time, c.time]);
a.dates = unique([b.dates, c.dates]);
end
a.nobs = size(a.data,1);
......@@ -110,7 +110,7 @@ function a = concatenate(b,c)
%$ B_name = {'B1';'B2'};
%$
%$ % Define expected results.
%$ e.time = dates(1,1);
%$ e.init = dates(1,1);
%$ e.freq = 1;
%$ e.name = {'A1';'A2';'B1';'B2'};
%$ e.data = [A,B];
......@@ -124,7 +124,7 @@ function a = concatenate(b,c)
%$
%$ % Check the results.
%$
%$ t(1) = dyn_assert(isequal(ts3.init,e.time),1);
%$ t(1) = dyn_assert(isequal(ts3.init,e.init),1);
%$ t(2) = dyn_assert(ts3.freq,e.freq);
%$ t(3) = dyn_assert(ts3.data,e.data);
%$ t(4) = dyn_assert(ts3.name,e.name);
......@@ -145,7 +145,6 @@ function a = concatenate(b,c)
%$ B_init = 2005;
%$
%$ % Define expected results.
%$ e.time = [transpose(2000+(1:12)), ones(12,1)];
%$ e.init = dates('2001Y');
%$ e.freq = 1;
%$ e.name = {'A1';'A2';'B1';'B2'};
......
......@@ -36,7 +36,5 @@ function b = isempty(A)
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT fr
b = isempty(A.data) && isequal(A.nobs,0) && isequal(A.vobs,0);
b = isempty(A.data) && isequal(A.nobs,0) && isequal(A.vobs,0);
\ No newline at end of file
......@@ -44,7 +44,7 @@ if isnumeric(B) && isreal(B) && isequal(length(B),1) && isa(C,'dseries')
A = dseries();
A.freq = C.freq;
A.init = C.init;
A.time = C.time;
A.dates = C.dates;
A.nobs = C.nobs;
A.vobs = C.vobs;
A.name = cell(A.vobs,1);
......@@ -61,7 +61,7 @@ if isnumeric(C) && isreal(C) && isequal(length(C),1) && isa(B,'dseries')
A = dseries();
A.freq = B.freq;
A.init = B.init;
A.time = B.time;
A.dates = B.dates;
A.nobs = B.nobs;
A.vobs = B.vobs;
A.name = cell(A.vobs,1);
......@@ -111,7 +111,7 @@ A = dseries();
A.freq = B.freq;
A.init = B.init;
A.time = B.time;
A.dates = B.dates;
A.nobs = max(B.nobs,C.nobs);
A.vobs = max(B.vobs,C.vobs);
A.name = cell(A.vobs,1);
......
......@@ -65,7 +65,7 @@ if isa(B,'dseries') && isa(C,'dseries')
A = dseries();
A.freq = B.freq;
A.init = B.init;
A.time = B.time;
A.dates = B.dates;
A.nobs = max(B.nobs,C.nobs);
A.vobs = max(B.vobs,C.vobs);
A.name = cell(A.vobs,1);
......@@ -79,7 +79,7 @@ elseif isnumeric(C) && isreal(C) && isequal(length(C),1) && isa(B,'dseries')
% division of a dseries object by a real scalar.
A = dseries();
A.freq = B.freq;
A.time = B.time;
A.dates = B.dates;
A.init = B.init;
A.nobs = B.nobs;
A.vobs = B.vobs;
......@@ -94,7 +94,7 @@ elseif isnumeric(B) && isreal(B) && isequal(length(B),1) && isa(C,'dseries')
% division of a real scalar by a dseries object.
A = dseries();
A.freq = C.freq;
A.time = C.time;
A.dates = C.dates;
A.init = C.init;
A.nobs = C.nobs;
A.vobs = C.vobs;
......
......@@ -65,7 +65,7 @@ if isa(B,'dseries') && isa(C,'dseries')
A = dseries();
A.freq = B.freq;
A.init = B.init;
A.time = B.time;
A.dates = B.dates;
A.nobs = max(B.nobs,C.nobs);
A.vobs = max(B.vobs,C.vobs);
A.name = cell(A.vobs,1);
......@@ -80,7 +80,7 @@ elseif isnumeric(C) && isreal(C) && isequal(length(C),1) && isa(B,'dseries')
A = dseries();
A.freq = B.freq;
A.init = B.init;
A.time = B.time;
A.dates = B.dates;
A.nobs = B.nobs;
A.vobs = B.vobs;
A.name = cell(A.vobs,1);
......@@ -95,7 +95,7 @@ elseif isnumeric(B) && isreal(B) && isequal(length(B),1) && isa(C,'dseries')
A = dseries();
A.freq = C.freq;
A.init = C.init;
A.time = C.time;
A.dates = C.dates;
A.nobs = C.nobs;
A.vobs = C.vobs;
A.name = cell(A.vobs,1);
......
......@@ -43,9 +43,9 @@ function A = plus(B,C) % --*-- Unitary tests --*--
if isscalar(B)
assert(isa(C, 'dseries'));
b(1:size(C)) = B;
BB = dseries(b, C.time(1));
BB = dseries(b, C.dates(1));
BB.freq = C.freq;
BB.time = C.time;
BB.dates = C.dates;
BB.nobs = C.nobs;
BB.vobs = C.vobs;
BB.name = cell(BB.vobs,1);
......@@ -58,9 +58,9 @@ end
if isscalar(C)
assert(isa(B, 'dseries'));
c(1:size(C)) = C;
CC = dseries(C, B.time(1));
CC = dseries(C, B.dates(1));
CC.freq = B.freq;
CC.time = B.time;
CC.dates = B.dates;
CC.nobs = B.nobs;
CC.vobs = B.vobs;
CC.name = cell(CC.vobs,1);
......@@ -116,7 +116,7 @@ for i=1:A.vobs
A.tex(i) = {['(' B.tex{idB(i)} '+' C.tex{idC(i)} ')']};
end
A.data = bsxfun(@plus,B.data,C.data);
A.time = A.init:A.init+(A.nobs-1);
A.dates = A.init:A.init+(A.nobs-1);
%@test:1
%$ % Define a datasets.
......
......@@ -82,9 +82,8 @@ switch format
fprintf(fid,',%s', A.name{:});
fprintf(fid,'\n');
for t=1:A.nobs
date = A.init+(t-1);
str = sprintf(', %15.8g',A.data(t,:));
fprintf(fid, '%s%s\n',date2string(date),str);
fprintf(fid, '%s%s\n',date2string(A.dates(t)),str);
end
fclose(fid);
end
......
......@@ -46,7 +46,7 @@ A.freq = B.freq;
A.nobs = B.nobs;
A.vobs = B.vobs;
A.init = B.init;
A.time = B.time;
A.dates = B.dates;
A.name = cell(A.vobs,1);
A.tex = cell(A.vobs,1);
for i = 1:A.vobs
......
......@@ -86,7 +86,7 @@ end
%$ B_name = {'A1';'A2'};
%$
%$ % Define expected results.
%$ e.time = dates(1,1);
%$ e.init = dates(1,1);
%$ e.freq = 1;
%$ e.name = {'A1';'A2'};
%$ e.data = [A;B];
......@@ -100,7 +100,7 @@ end
%$
%$ % Check the results.
%$
%$ t(1) = dyn_assert(isequal(ts3.init,e.time),1);
%$ t(1) = dyn_assert(isequal(ts3.init,e.init),1);
%$ t(2) = dyn_assert(ts3.freq,e.freq);
%$ t(3) = dyn_assert(ts3.data,e.data);
%$ t(4) = dyn_assert(ts3.name,e.name);
......@@ -121,7 +121,7 @@ end
%$ C_name = {'A1';'A2'};
%$
%$ % Define expected results.
%$ e.time = dates(1,1);
%$ e.init = dates(1,1);
%$ e.freq = 1;
%$ e.name = {'A1';'A2'};
%$ e.data = [A;B;C];
......@@ -136,7 +136,7 @@ end
%$
%$ % Check the results.
%$
%$ t(1) = dyn_assert(isequal(ts4.init,e.time),1);
%$ t(1) = dyn_assert(isequal(ts4.init,e.init),1);
%$ t(2) = dyn_assert(ts4.freq,e.freq);
%$ t(3) = dyn_assert(ts4.data,e.data);
%$ t(4) = dyn_assert(ts4.name,e.name);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment