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

Removed third argument.

Second argument of merge overwrites its first argument except if
second argument has NaNs (in this case first argument takes
precedence). This commit reverts fd7476e6 and adds a new unit test.
parent c9def378
Pipeline #2911 passed with stage
in 1 minute and 17 seconds
function q = merge(o, p, rewritewithnans) % --*-- Unitary tests --*--
function q = merge(o, p) % --*-- Unitary tests --*--
% Merge method for dseries objects.
%
% INPUTS
% - o [dseries]
% - p [dseries]
% - rewritewithnans [logical]
%
% OUTPUTS
% - q [dseries]
......@@ -55,10 +54,6 @@ 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');
......@@ -109,7 +104,7 @@ elseif firstdate(o) >= firstdate(p)
end
Z = [Z1 Z2];
q.data = Z(:,IBC);
if ~rewritewithnans && ~isempty(list_of_common_variables)
if ~isempty(list_of_common_variables)
for i=1:length(iP)
jO = iO(i);
jP = iP(i);
......@@ -133,7 +128,7 @@ else
end
Z = [Z2 Z1];
q.data = Z(:,IBC);
if ~rewritewithnans && ~isempty(list_of_common_variables)
if ~isempty(list_of_common_variables)
for i=1:length(iP)
jO = iO(i);
jP = iP(i);
......@@ -213,7 +208,7 @@ q.dates = q_init:q_init+(nobs(q)-1);
%@test:3
%$ % Define two dseries objects.
%$ y = dseries(ones(4,1),'1989Q1', 'u');
%$ z = dseries(ones(4,1),'1990Q1', 'u');
%$ z = dseries(2*ones(4,1),'1990Q1', 'u');
%$
%$ % Merge the two objects.
%$ try
......@@ -226,7 +221,7 @@ 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(4) = all(x.data(5:end)==2) && all(x.data(1:4)==1);
%$ t(5) = all(x.dates==dates('1989Q1'):dates('1990Q4'));
%$ end
%$ T = all(t);
......@@ -235,11 +230,11 @@ q.dates = q_init:q_init+(nobs(q)-1);
%@test:4
%$ % Define two dseries objects.
%$ y = dseries(ones(4,1),'1989Q1', 'u');
%$ z = dseries(ones(4,1),'1990Q1', 'u');
%$ z = dseries([NaN(4,1); 2*ones(4,1)],'1989Q1', 'u');
%$
%$ % Merge the two objects.
%$ try
%$ x = merge(y, z, false);
%$ x = merge(y, z);
%$ t(1) = true;
%$ catch
%$ t = false;
......@@ -248,7 +243,7 @@ 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, ones(8,1));
%$ t(4) = all(x.data(5:end)==2) && all(x.data(1:4)==1);
%$ t(5) = all(x.dates==dates('1989Q1'):dates('1990Q4'));
%$ end
%$ T = all(t);
......
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