Fixed bug in @dynSeries/subsasgn that pops up when length(S) is equal to two and S(1).type is a dot.
Allows Syntax like: ts.A1(rg) = B where ts is a dynSeries object, A1 is a variable in the database, rg is a dynDates object and B an array of doubles.time-shift
parent
627dda5fc0
commit
84522ce87f
|
@ -148,7 +148,11 @@ switch length(S)
|
||||||
case 2
|
case 2
|
||||||
merge_dynSeries_objects = 0;
|
merge_dynSeries_objects = 0;
|
||||||
if ((isequal(S(1).type,'{}') || isequal(S(1).type,'.')) && isequal(S(2).type,'()'))
|
if ((isequal(S(1).type,'{}') || isequal(S(1).type,'.')) && isequal(S(2).type,'()'))
|
||||||
sA = extract(A,S(1).subs{:});
|
if isequal(S(1).type,'{}')
|
||||||
|
sA = extract(A,S(1).subs{:});
|
||||||
|
else
|
||||||
|
sA = extract(A,S(1).subs);
|
||||||
|
end
|
||||||
if (isa(B,'dynSeries') && isequal(sA.vobs,B.vobs)) || (isnumeric(B) && isequal(sA.vobs,columns(B)))
|
if (isa(B,'dynSeries') && isequal(sA.vobs,B.vobs)) || (isnumeric(B) && isequal(sA.vobs,columns(B)))
|
||||||
if isa(S(2).subs{1},'dynDates') || isa(S(2).subs{1},'dynDate')
|
if isa(S(2).subs{1},'dynDates') || isa(S(2).subs{1},'dynDate')
|
||||||
[junk, tdx] = intersect(sA.time.time,S(2).subs{1}.time,'rows');
|
[junk, tdx] = intersect(sA.time.time,S(2).subs{1}.time,'rows');
|
||||||
|
@ -524,4 +528,35 @@ end
|
||||||
%$ t(7) = dyn_assert(ts1.data,[[A(1:2,1); B(3:7); A(8:end,1)], A(:,2:3)],1e-15);
|
%$ t(7) = dyn_assert(ts1.data,[[A(1:2,1); B(3:7); A(8:end,1)], A(:,2:3)],1e-15);
|
||||||
%$ end
|
%$ end
|
||||||
%$ T = all(t);
|
%$ T = all(t);
|
||||||
%@eof:13
|
%@eof:13
|
||||||
|
|
||||||
|
%@test:14
|
||||||
|
%$ % Define a datasets.
|
||||||
|
%$ A = rand(40,3); B = rand(40,1);
|
||||||
|
%$
|
||||||
|
%$ % Instantiate two dynSeries object.
|
||||||
|
%$ ts1 = dynSeries(A,'1950Q1',{'A1';'A2';'A3'},[]);
|
||||||
|
%$ ts2 = dynSeries(B,'1950Q1',{'B1'},[]);
|
||||||
|
%$
|
||||||
|
%$ % modify first object.
|
||||||
|
%$ try
|
||||||
|
%$ d1 = dynDate('1950Q3');
|
||||||
|
%$ d2 = dynDate('1951Q3');
|
||||||
|
%$ rg = d1:d2;
|
||||||
|
%$ ts1.A1(rg) = B(3:7);
|
||||||
|
%$ t(1) = 1;
|
||||||
|
%$ catch
|
||||||
|
%$ t(1) = 0;
|
||||||
|
%$ end
|
||||||
|
%$
|
||||||
|
%$ % Instantiate a time series object.
|
||||||
|
%$ if t(1)
|
||||||
|
%$ t(2) = dyn_assert(ts1.vobs,3);
|
||||||
|
%$ t(3) = dyn_assert(ts1.nobs,40);
|
||||||
|
%$ t(4) = dyn_assert(ts1.name{2},'A2');
|
||||||
|
%$ t(5) = dyn_assert(ts1.name{1},'A1');
|
||||||
|
%$ t(6) = dyn_assert(ts1.name{3},'A3');
|
||||||
|
%$ t(7) = dyn_assert(ts1.data,[[A(1:2,1); B(3:7); A(8:end,1)], A(:,2:3)],1e-15);
|
||||||
|
%$ end
|
||||||
|
%$ T = all(t);
|
||||||
|
%@eof:14
|
Loading…
Reference in New Issue