Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dynare
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
dynare
Commits
6e3a7319
Commit
6e3a7319
authored
9 years ago
by
Houtan Bastani
Browse files
Options
Downloads
Patches
Plain Diff
fix general oo_ conversion function: make recursive, works in both directions, #915
parent
f5c4ab7d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
matlab/convert_dyn_45_to_44.m
+30
-6
30 additions, 6 deletions
matlab/convert_dyn_45_to_44.m
matlab/convert_oo_.m
+51
-13
51 additions, 13 deletions
matlab/convert_oo_.m
with
81 additions
and
19 deletions
matlab/convert_dyn_45_to_44.m
+
30
−
6
View file @
6e3a7319
function
[]
=
convert_dyn_45_to_44
% function []=convert_dyn_45_to_44
% This function converts the oo_-structure fields that have been changed in Dynare 4.5.
% following https://github.com/DynareTeam/dynare/pull/771 to the old format
% of Dynare 4.4
function
oo_
=
convert_dyn_45_to_44
(
M_
,
options_
,
oo_
)
%function oo_ = convert_dyn_45_to_44(M_, options_, oo_
% Converts oo_ from 4.5 to 4.4
%
% INPUTS
% M_ [struct] dynare model struct
% options_ [struct] dynare options struct
% oo_ [struct] dynare output struct
%
% OUTPUTS
% oo_ [struct] dynare output struct
%
% SPECIAL REQUIREMENTS
% none
global
M_
oo_
options_
% Copyright (C) 2015 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along = with Dynare. If not, see <http://www.gnu.org/licenses/>.
%% add initial conditions to Bayesian forecasts
if
isfield
(
oo_
,
'PointForecast'
)
...
...
This diff is collapsed.
Click to expand it.
matlab/convert_oo_.m
+
51
−
13
View file @
6e3a7319
function
oo_
=
convert_oo_
(
oo_
,
ver
)
%function oo_ = convert_oo_(
oo_,
ver)
function
oo_
=
convert_oo_
(
M_
,
options_
,
oo_
,
from_ver
,
to_
ver
)
%function oo_ = convert_oo_(
M_, options_, oo_, from_ver, to_
ver)
% Converts oo_ from oo_.dynare_version to ver
%
% INPUTS
% oo_ [struct] dynare output struct
% ver [string] desired oo_ output version
% M_ [struct] dynare model struct
% options_ [struct] dynare options struct
% oo_ [struct] dynare output struct
% from_ver [string] original oo_ output version
% to_ver [string] desired oo_ output version
%
% OUTPUTS
% oo_ [struct] dynare output struct
% oo_
[struct] dynare output struct
%
% SPECIAL REQUIREMENTS
% none
...
...
@@ -27,21 +30,56 @@ function oo_ = convert_oo_(oo_, ver)
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% along
=
with Dynare. If not, see <http://www.gnu.org/licenses/>.
check_valid_ver
(
ver
);
check_valid_ver
(
to_ver
);
check_valid_ver
(
from_ver
);
if
isfield
(
oo_
,
'dynare_version'
)
ver_orig
=
oo_
.
dynare_version
;
MIN_VER
=
'4.4'
;
MAX_VER
=
'4.5'
;
if
ver_less_than
(
to_ver
,
MIN_VER
)
error
([
'Can only convert as far back as Dynare '
MIN_VER
'. All versions before have the same oo_ structure.'
]);
end
if
ver_greater_than
(
to_ver
,
MAX_VER
)
error
([
'Can only convert up to Dynare '
MAX_VER
]);
end
min_ver
=
strsplit
(
MIN_VER
,
{
'.'
,
'-'
});
max_ver
=
strsplit
(
MAX_VER
,
{
'.'
,
'-'
});
from_ver_split
=
strsplit
(
from_ver
,
{
'.'
,
'-'
});
to_ver_split
=
strsplit
(
to_ver
,
{
'.'
,
'-'
});
if
length
(
from_ver_split
)
~=
2
||
length
(
to_ver_split
)
~=
2
error
(
'The version numbers may only be of the form X.Y'
);
end
if
to_ver_split
{
2
}
>
from_ver_split
{
2
}
new_to_ver
=
[
to_ver_split
{
1
}
'.'
num2str
(
str2double
(
to_ver_split
{
2
})
-
1
)];
else
ver_orig
=
'4.4.3'
;
new_to_ver
=
[
to_ver_split
{
1
}
'.'
num2str
(
str2double
(
to_ver_split
{
2
})
+
1
)]
;
end
if
strcmp
(
ver_orig
,
ver
)
if
strcmp
(
from_ver
,
to_
ver
)
return
;
end
if
ver_less_than
(
ver_orig
,
'4.5.0'
)
&&
ver_greater_than_equal
(
ver
,
'4.5.0'
)
oo_
.
exo_simul
=
oo_
.
exo_simul
'
;
if
ver_greater_than
(
to_ver
,
from_ver
)
moving_up
=
1
;
else
moving_up
=
-
1
;
end
oo_
=
convert_oo_
(
M_
,
options_
,
oo_
,
from_ver
,
new_to_ver
)
if
abs
(
to_ver_split
{
2
}
-
(
from_ver_split
{
2
}
-
moving_up
))
>
1
new_from_ver
=
[
to_ver_split
{
1
}
'.'
num2str
(
str2double
(
to_ver_split
{
2
})
-
moving_up
)];
else
new_from_ver
=
from_ver
;
end
eval
([
'oo_ = convert_dyn_'
strrep
(
new_from_ver
,
'.'
,
''
)
'_to_'
...
strrep
(
to_ver
,
'.'
,
''
)
'(M_, options_, oo_);'
]);
end
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