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
04356a89
Commit
04356a89
authored
5 years ago
by
Stéphane Adjemian
Browse files
Options
Downloads
Patches
Plain Diff
Make new behaviour introduced in
c6def35e
optional.
(cherry picked from commit
fd7476e6
)
parent
b1b4136e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/@dseries/merge.m
+37
-8
37 additions, 8 deletions
src/@dseries/merge.m
with
37 additions
and
8 deletions
src/@dseries/merge.m
+
37
−
8
View file @
04356a89
function
q
=
merge
(
o
,
p
)
% --*-- Unitary tests --*--
function
q
=
merge
(
o
,
p
,
rewritewithnans
)
% --*-- Unitary tests --*--
% Merge method for dseries objects.
%
% INPUTS
% - o [dseries]
% - p [dseries]
% - o [dseries]
% - p [dseries]
% - rewritewithnans [logical]
%
% OUTPUTS
% - q [dseries]
% - q
[dseries]
%
% REMARKS
% If dseries objects o and p have common variables, the variables in p take precedence.
% If dseries objects o and p have common variables, the variables
% in p take precedence except if rewritewithnans is false and p has
% nans.
% Copyright © 2013-2019 Dynare Team
%
...
...
@@ -41,6 +44,10 @@ if ~isequal(frequency(o), frequency(p))
end
end
if
nargin
<
3
rewritewithnans
=
true
;
end
q
=
dseries
();
[
q
.
name
,
IBC
,
~
]
=
unique
([
o
.
name
;
p
.
name
],
'last'
);
...
...
@@ -91,7 +98,7 @@ elseif firstdate(o) >= firstdate(p)
end
Z
=
[
Z1
Z2
];
q
.
data
=
Z
(:,
IBC
);
if
~
isempty
(
list_of_common_variables
)
if
~
rewritewithnans
&&
~
isempty
(
list_of_common_variables
)
for
i
=
1
:
length
(
iP
)
jO
=
iO
(
i
);
jP
=
iP
(
i
);
...
...
@@ -115,7 +122,7 @@ else
end
Z
=
[
Z2
Z1
];
q
.
data
=
Z
(:,
IBC
);
if
~
isempty
(
list_of_common_variables
)
if
~
rewritewithnans
&&
~
isempty
(
list_of_common_variables
)
for
i
=
1
:
length
(
iP
)
jO
=
iO
(
i
);
jP
=
iP
(
i
);
...
...
@@ -208,8 +215,30 @@ q.dates = q_init:q_init+(nobs(q)-1);
%$ if t(1)
%$ t(2) = dassert(x.vobs,1);
%$ t(3) = dassert(x.name{1},'u');
%$ t(4) = dassert(x.data(5:end), ones(4,1)) && all(isnan(x.data(1:4)));
%$ t(5) = all(x.dates==dates('1989Q1'):dates('1990Q4'));
%$ end
%$ T = all(t);
%@eof:3
%@test:4
%$ % Define two dseries objects.
%$ y = dseries(ones(4,1),'1989Q1', 'u');
%$ z = dseries(ones(4,1),'1990Q1', 'u');
%$
%$ % Merge the two objects.
%$ try
%$ x = merge(y, z, false);
%$ t(1) = true;
%$ catch
%$ t = false;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(x.vobs,1);
%$ t(3) = dassert(x.name{1},'u');
%$ t(4) = dassert(x.data, ones(8,1));
%$ t(5) = all(x.dates==dates('1989Q1'):dates('1990Q4'));
%$ end
%$ T = all(t);
%@eof:3
\ No newline at end of file
%@eof:4
\ No newline at end of file
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