Skip to content
Snippets Groups Projects
Verified Commit 6d9220a1 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Removed weekly frequency + cosmetic changes.

parent 535fe8c0
No related branches found
No related tags found
No related merge requests found
function s = freq2string(freq) % --*-- Unitary tests --*--
% INPUTS
% o freq scalar integer, equal to 1, 2, 4, 12, 52 or 365 (resp. annual, bi-annual, quaterly, monthly, weekly or daily)
% - freq [integer] scalar equal to 1, 2, 4, 12, or 365 (resp. annual, bi-annual, quaterly, monthly, or daily)
%
% OUTPUTS
% o s character, equal to Y, H, Q, M, W or D (resp. annual, bi-annual, quaterly, monthly, weekly or daily)
% - s [char] scalar equal to Y, H, Q, M, or D (resp. annual, bi-annual, quaterly, monthly, or daily)
% Copyright (C) 2013-2020 Dynare Team
% Copyright © 2013-2020 Dynare Team
%
% This file is part of Dynare.
%
......@@ -32,46 +32,44 @@ switch freq
s = 'Q';
case 12
s = 'M';
case 52
s = 'W';
case 365
s = 'D';
otherwise
error('dates::freq2string: Unknown frequency!')
end
return
%@test:1
%$ try
%$ strY = freq2string(1);
%$ strH = freq2string(2);
%$ strQ = freq2string(4);
%$ strM = freq2string(12);
%$ strW = freq2string(52);
%$ strD = freq2string(365);
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(strY, 'Y');
%$ t(3) = dassert(strH, 'H');
%$ t(4) = dassert(strQ, 'Q');
%$ t(5) = dassert(strM, 'M');
%$ t(6) = dassert(strW, 'W');
%$ t(7) = dassert(strD, 'D');
%$ end
%$
%$ T = all(t);
try
strY = freq2string(1);
strH = freq2string(2);
strQ = freq2string(4);
strM = freq2string(12);
strD = freq2string(365);
t(1) = true;
catch
t(1) = false;
end
if t(1)
t(2) = isequal(strY, 'Y');
t(3) = isequal(strH, 'H');
t(4) = isequal(strQ, 'Q');
t(5) = isequal(strM, 'M');
t(6) = isequal(strD, 'D');
end
T = all(t);
%@eof:1
%@test:2
%$ try
%$ str = freq2string(13);
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ T = all(t);
try
str = freq2string(13);
t(1) = false;
catch
t(1) = true;
end
T = all(t);
%@eof:2
function freq = string2freq(s) % --*-- Unitary tests --*--
% INPUTS
% o s character, equal to Y, H, Q, M, W or D (resp. annual, bi-annual, quaterly, monthly, weekly or daily)
% - s [char] scalar equal to Y, H, Q, M, or D (resp. annual, bi-annual, quaterly, monthly, or daily)
%
% OUTPUTS
% o freq scalar integer, equal to 1, 2, 4, 12, 52 or 365 (resp. annual, bi-annual, quaterly, monthly, weekly or daily)
% - freq [integer] scalar equal to 1, 2, 4, 12, or 365 (resp. annual, bi-annual, quaterly, monthly, or daily)
% Copyright (C) 2013-2020 Dynare Team
% Copyright © 2013-2020 Dynare Team
%
% This file is part of Dynare.
%
......@@ -32,46 +32,44 @@ switch upper(s)
freq = 4;
case 'M'
freq = 12;
case 'W'
freq = 52;
case 'D'
freq = 365;
otherwise
error('dates::freq2string: Unknown frequency!')
end
return
%@test:1
%$ try
%$ nY = string2freq('Y');
%$ nH = string2freq('H');
%$ nQ = string2freq('Q');
%$ nM = string2freq('M');
%$ nW = string2freq('W');
%$ nD = string2freq('D');
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(nY, 1);
%$ t(3) = dassert(nH, 2);
%$ t(4) = dassert(nQ, 4);
%$ t(5) = dassert(nM, 12);
%$ t(6) = dassert(nW, 52);
%$ t(7) = dassert(nD, 365);
%$ end
%$
%$ T = all(t);
try
nY = string2freq('Y');
nH = string2freq('H');
nQ = string2freq('Q');
nM = string2freq('M');
nD = string2freq('D');
t(1) = true;
catch
t(1) = false;
end
if t(1)
t(2) = isequal(nY, 1);
t(3) = isequal(nH, 2);
t(4) = isequal(nQ, 4);
t(5) = isequal(nM, 12);
t(6) = isequal(nD, 365);
end
T = all(t);
%@eof:1
%@test:2
%$ try
%$ n = string2freq('Z');
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ T = all(t);
try
n = string2freq('Z');
t(1) = false;
catch
t(1) = true;
end
T = all(t);
%@eof:2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment