Commit fd7476e6 authored by Stéphane Adjemian's avatar Stéphane Adjemian

Make new behaviour introduced in c6def35e optional.

parent 03b2ea4f
Pipeline #2196 passed with stage
in 2 minutes and 38 seconds
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment