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

Bug fix. Wrong number of lines for time member if n<freq.

parent 9826bd98
Branches
Tags
No related merge requests found
...@@ -81,9 +81,9 @@ if isequal(C.freq,1) ...@@ -81,9 +81,9 @@ if isequal(C.freq,1)
C.time(:,2) = 1; C.time(:,2) = 1;
else else
C.time = NaN(n,2); C.time = NaN(n,2);
initperiods = C.freq-A.time(2)+1; initperiods = min(C.freq-A.time(2)+1,n);
C.time(1:initperiods,1) = A.time(1); C.time(1:initperiods,1) = A.time(1);
C.time(1:initperiods,2) = transpose(A.time(2):C.freq); C.time(1:initperiods,2) = transpose(A.time(2)-1+(1:initperiods));
if n>initperiods if n>initperiods
p = n-initperiods; p = n-initperiods;
if p<=C.freq if p<=C.freq
...@@ -99,6 +99,7 @@ else ...@@ -99,6 +99,7 @@ else
C.time(initperiods+C.freq+(1:r),2) = transpose(1:r); C.time(initperiods+C.freq+(1:r),2) = transpose(1:r);
end end
end end
end
if d>1 if d>1
C.time = C.time(1:d:n,:); C.time = C.time(1:d:n,:);
C.ndat = m; C.ndat = m;
...@@ -106,7 +107,6 @@ else ...@@ -106,7 +107,6 @@ else
C.ndat = n; C.ndat = n;
end end
end end
end
%@test:1 %@test:1
%$ % Define two dates %$ % Define two dates
...@@ -173,3 +173,20 @@ end ...@@ -173,3 +173,20 @@ end
%$ t(2) = dyn_assert(d.freq,e.freq); %$ t(2) = dyn_assert(d.freq,e.freq);
%$ T = all(t); %$ T = all(t);
%$ @eof:3 %$ @eof:3
%$ @test:4
%$ % Create an empty dates object for quaterly data
%$ qq = dates('Q');
%$
%$ % Define expected results.
%$ e.freq = 4;
%$ e.time = [1950 1; 1950 2; 1950 3];
%$
%$ % Call the tested routine.
%$ d = qq(1950,1):qq(1950,3);
%$
%$ % Check the results.
%$ t(1) = dyn_assert(d.time,e.time);
%$ t(2) = dyn_assert(d.freq,e.freq);
%$ T = all(t);
%$ @eof:4
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment