Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dseries
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
dseries
Commits
6d9220a1
Verified
Commit
6d9220a1
authored
4 years ago
by
Stéphane Adjemian
Browse files
Options
Downloads
Patches
Plain Diff
Removed weekly frequency + cosmetic changes.
parent
535fe8c0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/utilities/convert/freq2string.m
+33
-35
33 additions, 35 deletions
src/utilities/convert/freq2string.m
src/utilities/convert/string2freq.m
+33
-35
33 additions, 35 deletions
src/utilities/convert/string2freq.m
with
66 additions
and
70 deletions
src/utilities/convert/freq2string.m
+
33
−
35
View file @
6d9220a1
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
This diff is collapsed.
Click to expand it.
src/utilities/convert/string2freq.m
+
33
−
35
View file @
6d9220a1
function
freq
=
string2freq
(
s
)
% --*-- Unitary tests --*--
% INPUTS
%
o
s char
acter,
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment