Issue an error if two dynSeries objects with common variable names are concatenated. Added a unitary test.

time-shift
Stéphane Adjemian (Charybdis) 2013-03-20 15:31:45 +01:00
parent 4d09ee6ae2
commit 54ad672453
2 changed files with 30 additions and 1 deletions

View File

@ -237,3 +237,27 @@ end
%$ t(4) = dyn_assert(ts4.name,e.name);
%$ T = all(t);
%@eof:5
%@test:6
%$ % Define a data set.
%$ A = [transpose(1:10),2*transpose(1:10)];
%$ B = [transpose(1:10),2*transpose(1:10)];
%$
%$ % Define names
%$ A_name = {'A1';'A2'};
%$ B_name = {'B1';'A2'};
%$
%$ % Instantiate two time series objects.
%$ ts1 = dynSeries(A,[],A_name,[]);
%$ ts2 = dynSeries(B,[],B_name,[]);
%$
%$ % Call the tested method.
%$ try
%$ ts3 = [ts1,ts2];
%$ t = 0;
%$ catch
%$ t = 1;
%$ end
%$
%$ T = t;
%@eof:6

View File

@ -55,7 +55,12 @@ function a = horzcat2(b,c)
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
[n,message] = common_strings_in_cell_arrays(b.name,c.name);
if n
error(['dynSeries::horzcat: I cannot concatenate dynSeries objects with common variable names (' message ')!'])
end
if b.freq ~= c.freq
error('dynSeries::horzcat: All time series objects must have common frequency!')
else