dseries.m 17.1 KB
Newer Older
1
classdef dseries<handle % --*-- Unitary tests --*--
2

3
% Class for time series.
4

5
% Copyright (C) 2013-2019 Dynare Team
6
%
7
% This code is free software: you can redistribute it and/or modify
8 9 10 11
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
Stéphane Adjemian's avatar
Stéphane Adjemian committed
12
% Dynare dseries submodule is distributed in the hope that it will be useful,
13 14 15 16 17 18 19
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.

Stéphane Adjemian's avatar
Stéphane Adjemian committed
20 21 22 23 24
properties
    data  = [];         % Array of data (a column per variable, a row per observation)
    name  = {};         % Names of the variables.
    tex   = {};         % TeX names of the variables.
    dates = dates();    % Dates associated to the observations.
Stéphane Adjemian's avatar
Stéphane Adjemian committed
25
    ops   = {};         % History of operations on the variables.
26
    tags  = struct();   % User defined tags on the variables.
Stéphane Adjemian's avatar
Stéphane Adjemian committed
27
end
28

Stéphane Adjemian's avatar
Stéphane Adjemian committed
29
methods
30 31
        function o = dseries(varargin)
        % Constructor for the dseries class
Stéphane Adjemian's avatar
Stéphane Adjemian committed
32 33
        %
        % INPUTS
34 35 36 37 38 39
        %
        % - If no input arguments, the constructore returns an empty dseries object.
        %
        % - If only one input argument is provided, the behaviour of the constructor depends on the type of the argument:
        %  + varargin{1}  [dates]   Constructor will return a dseries object without data. The dseries object can be populated later using dseries' methods.
        %  + varargin{1}  [char]    The name of a csv, m, mat or xlsx file containing data. A dseries object is created from these data.
Stéphane Adjemian's avatar
Stéphane Adjemian committed
40
        %  + varargin{1}  [double]  A T*N array of data. A dseries object is created from the array (T observations, N variables).
41 42 43 44 45 46 47
        %
        % - If only one two, three or four arguments are provided, we must have:
        %  + varargin{1}  [double]      A T*N array of data.
        %  + varargin{2}  [dates, char] A single element dates object or a string representing a date, the initial date of the database.
        %  + varargin{3}  [cell]        A N*1 cell of char or a N*q array of char, the names of  the variables.
        %  + varargin{4}  [cell]        A N*1 cell of char or a N*q array of char, the TeX names of  the variables.
        %
Stéphane Adjemian's avatar
Stéphane Adjemian committed
48
        % OUTPUTS
49
        % - o [dseries]
Stéphane Adjemian's avatar
Stéphane Adjemian committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63
        switch nargin
          case 0
            % Return empty object.
            return
          case 1
            if isdates(varargin{1})
                switch length(varargin{1})
                  case 0
                    error('dseries:WrongInputArguments', 'Input (identified as a dates object) must be non empty!');
                  case 1
                    % Create an empty dseries object with an initial date.
                    o.dates = varargin{1};
                  otherwise
                    error('dseries:WrongInputArguments', 'Input (identified as a dates object) must have a unique element!');
64
                end
Stéphane Adjemian's avatar
Stéphane Adjemian committed
65 66
                return
            elseif ischar(varargin{1})
67
                [init, o.data, o.name, o.tex, o.ops, o.tags] = load_data(varargin{1});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
68
                o.dates = init:init+(nobs(o)-1);
Stéphane Adjemian's avatar
Stéphane Adjemian committed
69
            elseif ~isoctave() && ~matlab_ver_less_than('8.2') && istable(varargin{1})
Stéphane Adjemian's avatar
Stéphane Adjemian committed
70 71 72 73 74
                % It is assumed that the dates are in the first column.
                o.name = varargin{1}.Properties.VariableNames(2:end);
                o.tex = name2tex(o.name);
                o.data = varargin{1}{:,2:end};
                o.dates = dates(varargin{1}{1,1}{1})+(0:size(varargin{1}, 1)-1);
Stéphane Adjemian's avatar
Stéphane Adjemian committed
75
                o.ops = cell(length(o.name), 1);
Stéphane Adjemian's avatar
Stéphane Adjemian committed
76 77 78 79 80
            elseif isnumeric(varargin{1}) && isequal(ndims(varargin{1}),2)
                o.data = varargin{1};
                o.name = default_name(vobs(o));
                o.tex = name2tex(o.name);
                o.dates = dates(1,1):dates(1,1)+(nobs(o)-1);
Stéphane Adjemian's avatar
Stéphane Adjemian committed
81
                o.ops = cell(length(o.name), 1);
82 83
            elseif isstruct(varargin{1})
                o = struct2dseries(varargin{1});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
84 85 86 87 88 89
            end
          case  {2,3,4}
            if isequal(nargin,2) && ischar(varargin{1}) && isdates(varargin{2})
                % Instantiate dseries object with a data file and force the initial date to
                % be as given by the second input argument (initial period represented
                % with a dates object).
90
                [~, o.data, o.name, o.tex, o.ops, o.tags] = load_data(varargin{1});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
91 92 93 94 95 96 97
                o.dates = varargin{2}:varargin{2}+(nobs(o)-1);
                return
            end
            if isequal(nargin,2) && ischar(varargin{1}) && ischar(varargin{2}) && isdate(varargin{2})
                % Instantiate dseries object with a data file and force the initial date to
                % be as given by the second input argument (initial period represented with a
                % string).
98
                [~, o.data, o.name, o.tex, o.ops, o.tags] = load_data(varargin{1});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
99 100 101 102 103 104 105 106 107 108 109
                o.dates = dates(varargin{2}):dates(varargin{2})+(nobs(o)-1);
                return
            end
            a = varargin{1};
            b = varargin{2};
            if nargin<4
                d = {};
            else
                d = varargin{4};
                if ~iscell(d) && ~isempty(d)
                    d = cellstr(d);
110
                end
Stéphane Adjemian's avatar
Stéphane Adjemian committed
111 112 113 114 115 116 117
            end
            if nargin<3
                c = {};
            else
                c = varargin{3};
                if ~iscell(c) && ~isempty(c)
                    c = cellstr(c);
118
                end
Stéphane Adjemian's avatar
Stéphane Adjemian committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
            end
            % Get data, number of observations and number of variables.
            o.data = a;
            % Get the first date and set the frequency.
            if isempty(b)
                init = dates(1,1);
            elseif (isdates(b) && isequal(length(b),1))
                init = b;
            elseif ischar(b) && isdate(b)% Weekly, Monthly, Quaterly or Annual data (string).
                init = dates(b);
            elseif (isnumeric(b) && isscalar(b) && isint(b)) % Yearly data.
                init = dates([num2str(b) 'Y']);
            elseif isdates(b) % Range of dates
                init = b(1);
                if nobs(o)>1 && ~isequal(b.ndat(),nobs(o))
                    error('dseries:WrongInputArguments', ['If second input is a range, its number ' ...
                                        'of elements must match\nthe number of rows in the ' ...
                                        'first input, unless the first input\nhas only one row.']);
                elseif isequal(nobs(o), 1)
                    o.data = repmat(o.data,b.ndat(),1);
139
                end
Stéphane Adjemian's avatar
Stéphane Adjemian committed
140 141 142 143 144 145 146 147 148 149 150 151 152
                o.dates = b;
            elseif (isnumeric(b) && isint(b)) % Range of yearly dates.
                error('dseries:WrongInputArguments', ['Not implemented! If you need to define ' ...
                                    'a range of years, you have to pass a dates object as the ' ...
                                    'second input argument']);
            else
                error('dseries:WrongInputArguments', 'Wrong calling sequence! Please check the manual.');
            end
            % Get the names of the variables.
            if ~isempty(c)
                if vobs(o)==length(c)
                    for i=1:vobs(o)
                        o.name = vertcat(o.name, c(i));
153 154
                    end
                else
Stéphane Adjemian's avatar
Stéphane Adjemian committed
155
                    error('dseries:WrongInputArguments', 'The number of declared names does not match the number of variables!')
156
                end
Stéphane Adjemian's avatar
Stéphane Adjemian committed
157 158 159
            else
                o.name = default_name(vobs(o));
            end
Stéphane Adjemian's avatar
Stéphane Adjemian committed
160
            o.ops = cell(length(o.name), 1);
161
            o.tags = struct();
Stéphane Adjemian's avatar
Stéphane Adjemian committed
162 163 164 165
            if ~isempty(d)
                if vobs(o)==length(d)
                    for i=1:vobs(o)
                        o.tex = vertcat(o.tex, d(i));
166 167
                    end
                else
Stéphane Adjemian's avatar
Stéphane Adjemian committed
168
                    error('dseries:WrongInputArguments', 'The number of declared tex names does not match the number of variables!')
169
                end
Stéphane Adjemian's avatar
Stéphane Adjemian committed
170 171
            else
                o.tex = name2tex(o.name);
172
            end
Stéphane Adjemian's avatar
Stéphane Adjemian committed
173 174 175 176 177 178
          otherwise
            error('dseries:WrongInputArguments', 'Wrong calling sequence! Please check the manual.')
        end
        if isempty(o.dates)
            o.dates = init:init+(nobs(o)-1);
        end
179
        end % dseries
Stéphane Adjemian's avatar
Stéphane Adjemian committed
180
end % methods
181
end % classdef
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215

%@test:1
%$ % Test if we can instantiate an empty dseries object.
%$ try
%$     ts = dseries();
%$     t(1) = 1;
%$ catch
%$     t(1) = 0;
%$ end
%$
%$ T = all(t);
%@eof:1

%@test:2
%$ t = zeros(4,1);
%$
%$ try
%$     aa = dates('1938M11');
%$     ts = dseries(aa);
%$     t(1) = 1;
%$ catch
%$     t = 0;
%$ end
%$
%$ if length(t)>1
%$     t(2) = dassert(ts.freq,12);
%$     t(3) = dassert(ts.init.freq,12);
%$     t(4) = dassert(ts.init.time,[1938, 11]);
%$ end
%$
%$ T = all(t);
%@eof:2

%@test:3
Stéphane Adjemian's avatar
Stéphane Adjemian committed
216
%$ t = zeros(8, 1);
217 218
%$
%$ try
219 220
%$     dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m','');
%$     ts = dseries([ dseries_src_root '../tests/data/dynseries_test_data.m' ]);
221 222 223 224 225 226 227 228 229 230 231
%$     t(1) = 1;
%$ catch
%$     t = 0;
%$ end
%$
%$ if length(t)>1
%$     t(2) = dassert(ts.freq,4);
%$     t(3) = dassert(ts.init.freq,4);
%$     t(4) = dassert(ts.init.time,[1994, 3]);
%$     t(5) = dassert(ts.vobs,2);
%$     t(6) = dassert(ts.nobs,100);
Stéphane Adjemian's avatar
Stéphane Adjemian committed
232 233
%$     t(7) = dassert(length(ts.ops), 2);
%$     t(8) = isempty(ts.ops{1}) && isempty(ts.ops{2});
234 235 236 237 238 239
%$ end
%$
%$ T = all(t);
%@eof:3

%@test:4
Stéphane Adjemian's avatar
Stéphane Adjemian committed
240
%$ t = zeros(8, 1);
241 242
%$
%$ try
243 244
%$     dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m','');
%$     ts = dseries([ dseries_src_root '../tests/data/dynseries_test_data.mat' ]);
245 246 247 248 249 250 251 252 253 254 255
%$     t(1) = 1;
%$ catch
%$     t = 0;
%$ end
%$
%$ if length(t)>1
%$     t(2) = dassert(ts.freq,4);
%$     t(3) = dassert(ts.init.freq,4);
%$     t(4) = dassert(ts.init.time,[1994, 3]);
%$     t(5) = dassert(ts.vobs,2);
%$     t(6) = dassert(ts.nobs,100);
Stéphane Adjemian's avatar
Stéphane Adjemian committed
256 257
%$     t(7) = dassert(length(ts.ops), 2);
%$     t(8) = isempty(ts.ops{1}) && isempty(ts.ops{2});
258 259 260 261 262 263
%$ end
%$
%$ T = all(t);
%@eof:4

%@test:5
Stéphane Adjemian's avatar
Stéphane Adjemian committed
264
%$ t = zeros(10, 1);
265 266
%$
%$ try
267 268
%$     dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m','');
%$     ts = dseries([ dseries_src_root '../tests/data/dynseries_test_data.csv' ]);
269 270 271 272 273 274 275 276 277 278 279 280 281
%$     t(1) = 1;
%$ catch
%$     t = 0;
%$ end
%$
%$ if length(t)>1
%$     t(2) = dassert(ts.freq,4);
%$     t(3) = dassert(ts.init.freq,4);
%$     t(4) = dassert(ts.init.time,[1990, 1]);
%$     t(5) = dassert(ts.vobs,4);
%$     t(6) = dassert(ts.nobs,4);
%$     t(7) = dassert(ts.name,{'azert';'yuiop';'qsdfg';'jklm'});
%$     t(8) = dassert(ts.tex,{'azert';'yuiop';'qsdfg';'jklm'});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
282 283
%$     t(9) = dassert(length(ts.ops), 4);
%$     t(10) = isempty(ts.ops{1}) && isempty(ts.ops{2}) && isempty(ts.ops{3}) && isempty(ts.ops{4}) ;
284 285 286 287 288 289
%$ end
%$
%$ T = all(t);
%@eof:5

%@test:6
Stéphane Adjemian's avatar
Stéphane Adjemian committed
290
%$ t = zeros(10, 1);
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
%$
%$ try
%$     ts = dseries(transpose(1:5),[]);
%$     t(1) = 1;
%$ catch
%$     t = 0;
%$ end
%$
%$ if length(t)>1
%$     t(2) = dassert(ts.freq,1);
%$     t(3) = dassert(ts.init.freq,1);
%$     t(4) = dassert(ts.init.time,[1, 1]);
%$     t(5) = dassert(ts.vobs,1);
%$     t(6) = dassert(ts.nobs,5);
%$     t(7) = dassert(ts.name,{'Variable_1'});
%$     t(8) = dassert(ts.tex,{'Variable\\_1'});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
307 308
%$     t(9) = dassert(length(ts.ops), 1);
%$     t(10) = isempty(ts.ops{1});
309 310 311 312 313 314
%$ end
%$
%$ T = all(t);
%@eof:6

%@test:7
Stéphane Adjemian's avatar
Stéphane Adjemian committed
315
%$ t = zeros(10, 1);
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
%$
%$ try
%$     ts = dseries(transpose(1:5),'1950Q1');
%$     t(1) = 1;
%$ catch
%$     t = 0;
%$ end
%$
%$ if length(t)>1
%$     t(2) = dassert(ts.freq,4);
%$     t(3) = dassert(ts.init.freq,4);
%$     t(4) = dassert(ts.init.time,[1950, 1]);
%$     t(5) = dassert(ts.vobs,1);
%$     t(6) = dassert(ts.nobs,5);
%$     t(7) = dassert(ts.name,{'Variable_1'});
%$     t(8) = dassert(ts.tex,{'Variable\\_1'});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
332 333
%$     t(9) = dassert(length(ts.ops), 1);
%$     t(10) = isempty(ts.ops{1});
334 335 336 337 338 339
%$ end
%$
%$ T = all(t);
%@eof:7

%@test:8
Stéphane Adjemian's avatar
Stéphane Adjemian committed
340
%$ t = zeros(10, 1);
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
%$
%$ try
%$     ts = dseries([transpose(1:5), transpose(6:10)],'1950q1',{'Output'; 'Consumption'}, {'Y_t'; 'C_t'});
%$     t(1) = 1;
%$ catch
%$     t = 0;
%$ end
%$
%$ if length(t)>1
%$     t(2) = dassert(ts.freq,4);
%$     t(3) = dassert(ts.init.freq,4);
%$     t(4) = dassert(ts.init.time,[1950, 1]);
%$     t(5) = dassert(ts.vobs,2);
%$     t(6) = dassert(ts.nobs,5);
%$     t(7) = dassert(ts.name,{'Output'; 'Consumption'});
%$     t(8) = dassert(ts.tex,{'Y_t'; 'C_t'});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
357 358
%$     t(9) = dassert(length(ts.ops), 2);
%$     t(10) = isempty(ts.ops{1}) && isempty(ts.ops{2});
359 360 361 362 363 364 365
%$ end
%$
%$ T = all(t);
%@eof:8

%@test:9
%$ try
366
%$     dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m','');
367
%$     if isoctave()
368
%$         ts = dseries([ dseries_src_root '../tests/data/dynseries_test_data-1.xlsx' ]);
369
%$     else
370
%$         ts = dseries([ dseries_src_root '../tests/data/dynseries_test_data-1.xls' ]);
371
%$     end
372 373 374 375 376 377 378 379 380 381 382 383 384
%$     t(1) = 1;
%$ catch
%$     t(1) = 0;
%$ end
%$
%$ if t(1)
%$     t(2) = dassert(ts.freq,4);
%$     t(3) = dassert(ts.init.freq,4);
%$     t(4) = dassert(ts.init.time,[1990, 1]);
%$     t(5) = dassert(ts.vobs,3);
%$     t(6) = dassert(ts.nobs,5);
%$     t(7) = dassert(ts.name,{'GDP';'Consumption';'CPI'});
%$     t(8) = dassert(ts.tex,{'GDP';'Consumption';'CPI'});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
385 386
%$     t(9) = dassert(length(ts.ops), 3);
%$     t(10) = isempty(ts.ops{1}) && isempty(ts.ops{2}) && isempty(ts.ops{3});
387 388 389 390 391 392 393
%$ end
%$
%$ T = all(t);
%@eof:9

%@test:10
%$ try
394
%$     dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m','');
395
%$     if isoctave()
396
%$         ts = dseries([ dseries_src_root '../tests/data/dynseries_test_data-2.xlsx' ]);
397
%$     else
398
%$         ts = dseries([ dseries_src_root '../tests/data/dynseries_test_data-2.xls' ]);
399
%$     end
400 401 402 403 404 405 406 407 408 409 410 411 412
%$     t(1) = 1;
%$ catch
%$     t(1) = 0;
%$ end
%$
%$ if t(1)
%$     t(2) = dassert(ts.freq,4);
%$     t(3) = dassert(ts.init.freq,4);
%$     t(4) = dassert(ts.init.time,[1990, 1]);
%$     t(5) = dassert(ts.vobs,3);
%$     t(6) = dassert(ts.nobs,5);
%$     t(7) = dassert(ts.name,{'Variable_1';'Variable_2';'Variable_3'});
%$     t(8) = dassert(ts.tex,{'Variable\\_1';'Variable\\_2';'Variable\\_3'});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
413 414
%$     t(9) = dassert(length(ts.ops), 3);
%$     t(10) = isempty(ts.ops{1}) && isempty(ts.ops{2}) && isempty(ts.ops{3});
415 416 417 418 419 420 421
%$ end
%$
%$ T = all(t);
%@eof:10

%@test:11
%$ try
422
%$     dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m','');
423
%$     if isoctave()
424
%$         ts = dseries([ dseries_src_root '../tests/data/dynseries_test_data-3.xlsx' ]);
425
%$     else
426
%$         ts = dseries([ dseries_src_root '../tests/data/dynseries_test_data-3.xls' ]);
427
%$     end
428 429 430 431 432 433 434 435 436 437 438 439 440
%$     t(1) = 1;
%$ catch
%$     t(1) = 0;
%$ end
%$
%$ if t(1)
%$     t(2) = dassert(ts.freq,1);
%$     t(3) = dassert(ts.init.freq,1);
%$     t(4) = dassert(ts.init.time,[1, 1]);
%$     t(5) = dassert(ts.vobs,3);
%$     t(6) = dassert(ts.nobs,5);
%$     t(7) = dassert(ts.name,{'Variable_1';'Variable_2';'Variable_3'});
%$     t(8) = dassert(ts.tex,{'Variable\\_1';'Variable\\_2';'Variable\\_3'});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
441 442
%$     t(9) = dassert(length(ts.ops), 3);
%$     t(10) = isempty(ts.ops{1}) && isempty(ts.ops{2}) && isempty(ts.ops{3});
443 444 445 446 447 448 449
%$ end
%$
%$ T = all(t);
%@eof:11

%@test:12
%$ try
450
%$     dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m','');
451
%$     if isoctave()
452
%$         ts = dseries([ dseries_src_root '../tests/data/dynseries_test_data-4.xlsx' ]);
453
%$     else
454
%$         ts = dseries([ dseries_src_root '../tests/data/dynseries_test_data-4.xls' ]);
455
%$     end
456 457 458 459 460 461 462 463 464 465 466 467 468
%$     t(1) = 1;
%$ catch
%$     t(1) = 0;
%$ end
%$
%$ if t(1)
%$     t(2) = dassert(ts.freq,1);
%$     t(3) = dassert(ts.init.freq,1);
%$     t(4) = dassert(ts.init.time,[1, 1]);
%$     t(5) = dassert(ts.vobs,3);
%$     t(6) = dassert(ts.nobs,5);
%$     t(7) = dassert(ts.name,{'GDP';'Consumption';'CPI'});
%$     t(8) = dassert(ts.tex,{'GDP';'Consumption';'CPI'});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
469 470
%$     t(9) = dassert(length(ts.ops), 3);
%$     t(10) = isempty(ts.ops{1}) && isempty(ts.ops{2}) && isempty(ts.ops{3});
471 472 473 474 475 476
%$ end
%$
%$ T = all(t);
%@eof:12

%@test:13
Stéphane Adjemian's avatar
Stéphane Adjemian committed
477
%$ t = zeros(8, 1);
478 479 480 481 482 483 484 485 486 487 488 489 490 491
%$
%$ try
%$     ts = dseries(transpose(1:4),dates('1990Q1'):dates('1990Q4'));
%$     t(1) = 1;
%$ catch
%$     t = 0;
%$ end
%$
%$ if length(t)>1
%$     t(2) = dassert(ts.freq,4);
%$     t(3) = dassert(ts.init.freq,4);
%$     t(4) = dassert(ts.init.time,[1990, 1]);
%$     t(5) = dassert(ts.vobs,1);
%$     t(6) = dassert(ts.nobs,4);
Stéphane Adjemian's avatar
Stéphane Adjemian committed
492 493
%$     t(7) = dassert(length(ts.ops), 1);
%$     t(8) = isempty(ts.ops{1});
494 495 496 497 498 499
%$ end
%$
%$ T = all(t);
%@eof:13

%@test:14
Stéphane Adjemian's avatar
Stéphane Adjemian committed
500
%$ t = zeros(9, 1);
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
%$
%$ try
%$     ts = dseries([1, 2],dates('1990Q1'):dates('1990Q4'));
%$     t(1) = 1;
%$ catch
%$     t = 0;
%$ end
%$
%$ if length(t)>1
%$     t(2) = dassert(ts.freq,4);
%$     t(3) = dassert(ts.init.freq,4);
%$     t(4) = dassert(ts.init.time,[1990, 1]);
%$     t(5) = dassert(ts.vobs,2);
%$     t(6) = dassert(ts.nobs,4);
%$     t(7) = dassert(ts.data, [ones(4,1), 2*ones(4,1)]);
Stéphane Adjemian's avatar
Stéphane Adjemian committed
516 517
%$     t(8) = dassert(length(ts.ops), 2);
%$     t(9) = isempty(ts.ops{1}) && isempty(ts.ops{2});
518 519 520 521 522 523 524
%$ end
%$
%$ T = all(t);
%@eof:14

%@test:15
%$ try
Stéphane Adjemian's avatar
Stéphane Adjemian committed
525
%$     evalc('dseries([1; 2],dates(''1990Q1''):dates(''1990Q4''));');
526 527 528 529 530 531 532
%$     t = 0;
%$ catch
%$     t = 1;
%$ end
%$
%$ T = all(t);
%@eof:15