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

Added shortcircuit in lead and lag methods if p==0.

parent 094eafdd
......@@ -50,10 +50,16 @@ if p<0
error('dseries:WrongInputArguments','Second input argument must be non negative! Use lead method instead.')
end
% Check that p is an integer
if ~isint(p)
error('dseries:WrongInputArguments','Second input argument must be an integer!')
end
% Return without changing anything if p==0
if ~p
return
end
% Update data member
o.data = [NaN(p, vobs(o)); o.data(1:end-p,:)];
......@@ -81,4 +87,22 @@ end
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
%@eof:1
%@test:2
%$ try
%$ data = transpose(0:1:50);
%$ ts = dseries(data,'1950Q1');
%$ ts.lag_(0);
%$ t(1) = 1;
%$ catch
%$ t(1) = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(ts.data,data,1e-15);
%$ t(3) = isempty(ts.ops)
%$ end
%$
%$ T = all(t);
%@eof:2
\ No newline at end of file
......@@ -50,10 +50,16 @@ if p<0
error('dseries:WrongInputArguments','Second input argument must be non negative! Use lag method instead.')
end
% Check that p is an integer
if ~isint(p)
error('dseries:WrongInputArguments','Second input argument must be an integer!')
end
% Return without changing anything if p==0
if ~p
return
end
% Update data member
o.data = [ o.data(p+1:end,:); NaN(p, vobs(o));];
......@@ -98,4 +104,22 @@ end
%$ end
%$
%$ T = all(t);
%@eof:2
\ No newline at end of file
%@eof:2
%@test:3
%$ try
%$ data = transpose(0:1:50);
%$ ts = dseries(data,'1950Q1');
%$ ts.lead_(0);
%$ t(1) = 1;
%$ catch
%$ t(1) = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(ts.data,data,1e-15);
%$ t(3) = isempty(ts.ops)
%$ end
%$
%$ T = all(t);
%@eof:3
\ No newline at end of file
Markdown is supported
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