Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • dynare-4.6
  • dynare-5.x
  • dynare-6.x
  • master
  • master-dist
  • master-with-fame-io
  • old-oop-style
  • path_setting
8 results

Target

Select target project
  • Dynare/dseries
  • sebastien/dseries
  • houtanb/dseries
  • DoraK/dseries
  • wmutschl/dseries
  • JohannesPfeifer/dseries
6 results
Select Git revision
  • dynare-4.6
  • dynare-4.7
  • fractional_ticks
  • master
  • master-dist
  • master-with-fame-io
  • old-oop-style
  • path_setting
  • xls_range
9 results
Show changes
Showing
with 93 additions and 81 deletions
function o = center_(o, geometric) % --*-- Unitary tests --*--
function o = center_(o, geometric)
% Centers dseries object o around its mean (arithmetic or geometric).
%
......@@ -9,7 +9,7 @@ function o = center_(o, geometric) % --*-- Unitary tests --*--
% OUTPUTS
% - o dseries object.
% Copyright © 2016-2021 Dynare Team
% Copyright © 2016-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -46,7 +46,7 @@ for i=1:o.vobs
end
end
return
return % --*-- Unit tests --*--
%@test:1
% Define a dataset.
......
function q = chain(o, p) % --*-- Unitary tests --*--
function q = chain(o, p)
% Chains two dseries objects.
%
......@@ -13,7 +13,7 @@ function q = chain(o, p) % --*-- Unitary tests --*--
% The two dseries objects must have common frequency and the same number of variables. Also the
% two samples must overlap.
% Copyright © 2014-2021 Dynare Team
% Copyright © 2014-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -33,7 +33,7 @@ function q = chain(o, p) % --*-- Unitary tests --*--
q = copy(o);
q.chain_(p);
return
return % --*-- Unit tests --*--
%@test:1
try
......@@ -57,4 +57,4 @@ if t(1)
end
T = all(t);
%@eof:1
\ No newline at end of file
%@eof:1
function o = chain_(o, p) % --*-- Unitary tests --*--
function o = chain_(o, p)
% Copyright © 2014-2021 Dynare Team
% Copyright © 2014-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -27,7 +27,7 @@ end
if vobs(o)-vobs(p)
if noinputname
error(['dseries::chain: dseries objects must have the same number of variables!'])
error('dseries::chain: dseries objects must have the same number of variables!')
else
error(['dseries::chain: dseries objects ' inputname(1) ' and ' inputname(2) ' must have the same number of variables!'])
end
......@@ -35,7 +35,7 @@ end
if frequency(o)-frequency(p)
if noinputname
error(['dseries::chain: dseries objects must have common frequencies!'])
error('dseries::chain: dseries objects must have common frequencies!')
else
error(['dseries::chain: dseries objects ' inputname(1) ' and ' inputname(2) ' must have common frequencies!'])
end
......@@ -77,7 +77,7 @@ for i=1:o.vobs
end
end
return
return % --*-- Unit tests --*--
%@test:1
try
......@@ -124,4 +124,4 @@ if t(1)
end
T = all(t);
%@eof:2
\ No newline at end of file
%@eof:2
function [error_flag, message] = check(o)
% Copyright (C) 2013-2017 Dynare Team
% Copyright © 2013-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -21,7 +21,7 @@ error_flag = 0;
[n,m] = size(o.data);
if ~isequal(m, vobs(o));
if ~isequal(m, vobs(o))
error_flag = 1;
if nargout>1
message = ['dseries: Wrong number of variables in dseries object ''' inputname(1) '''!'];
......@@ -29,7 +29,7 @@ if ~isequal(m, vobs(o));
return
end
if ~isequal(n,nobs(o));
if ~isequal(n,nobs(o))
error_flag = 1;
if nargout>1
message = ['dseries: Wrong number of observations in dseries object ''' inputname(1) '''!'];
......@@ -37,7 +37,7 @@ if ~isequal(n,nobs(o));
return
end
if ~isequal(m,numel(o.name));
if ~isequal(m,numel(o.name))
error_flag = 1;
if nargout>1
message = ['dseries: Wrong number of variable names in dseries object ''' inputname(1) '''!'];
......@@ -45,7 +45,7 @@ if ~isequal(m,numel(o.name));
return
end
if ~isequal(m,numel(o.tex));
if ~isequal(m,numel(o.tex))
error_flag = 1;
if nargout>1
message = ['dseries: Wrong number of variable tex names in dseries object ''' inputname(1) '''!'];
......@@ -53,7 +53,7 @@ if ~isequal(m,numel(o.tex));
return
end
if ~isequal(numel(o.name), numel(o.tex));
if ~isequal(numel(o.name), numel(o.tex))
error_flag = 1;
if nargout>1
message = ['dseries: The number of variable tex names has to be equal to the number of variable names in dseries object ''' inputname(1) '''!'];
......@@ -61,7 +61,7 @@ if ~isequal(numel(o.name), numel(o.tex));
return
end
if ~isequal(numel(unique(o.name)), numel(o.name));
if ~isequal(numel(unique(o.name)), numel(o.name))
error_flag = 1;
if nargout>1
message = ['dseries: The variable names in dseries object ''' inputname(1) ''' are not unique!'];
......@@ -69,7 +69,7 @@ if ~isequal(numel(unique(o.name)), numel(o.name));
return
end
if ~isequal(numel(unique(o.tex)), numel(o.tex));
if ~isequal(numel(unique(o.tex)), numel(o.tex))
error_flag = 1;
if nargout>1
message = ['dseries: The variable tex names in dseries object ''' inputname(1) ''' are not unique!'];
......@@ -83,4 +83,4 @@ if ~isequal(o.dates, firstdate(o):firstdate(o)+nobs(o))
message = ['dseries: Wrong definition of the dates member in dseries object ''' inputname(1) '''!'];
end
return
end
\ No newline at end of file
end
function p = copy(o) % --*-- Unitary tests --*--
function p = copy(o)
% Do a copy of a dseries object.
%
......@@ -8,7 +8,7 @@ function p = copy(o) % --*-- Unitary tests --*--
% OUTPUTS
% - p [dates]
% Copyright © 2015-2021 Dynare Team
% Copyright © 2015-2023 Dynare Team
%
% This code is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
......@@ -31,7 +31,7 @@ p.dates = o.dates;
p.ops = o.ops;
p.tags = o.tags;
return
return % --*-- Unit tests --*--
%@test:1
% Define a dates object
......@@ -53,4 +53,4 @@ if t(1)
end
T = all(t);
%@eof:1
\ No newline at end of file
%@eof:1
function o = cumprod(varargin) % --*-- Unitary tests --*--
function o = cumprod(varargin)
% Overloads matlab's cumprod function for dseries objects.
%
......@@ -10,7 +10,7 @@ function o = cumprod(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - B dseries object.
% Copyright © 2014-2021 Dynare Team
% Copyright © 2014-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -39,7 +39,7 @@ else
end
end
return
return % --*-- Unit tests --*--
%@test:1
% Define a data set.
......
function o = cumprod_(varargin) % --*-- Unitary tests --*--
function o = cumprod_(varargin)
% Overloads matlab's cumprod function for dseries objects.
%
......@@ -10,7 +10,7 @@ function o = cumprod_(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - o dseries object.
% Copyright © 2014-2021 Dynare Team
% Copyright © 2014-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -128,7 +128,7 @@ switch nargin
error('dseries::cumprod: Wrong number of input arguments!')
end
return
return % --*-- Unit tests --*--
%@test:1
% Define a data set.
......@@ -291,4 +291,4 @@ if t(1)
t(2) = dassert(ts0.data, A);
end
T = all(t);
%@eof:6
\ No newline at end of file
%@eof:6
function o = cumsum(varargin) % --*-- Unitary tests --*--
function o = cumsum(varargin)
% Overloads matlab's cumsum function for dseries objects.
%
......@@ -10,7 +10,7 @@ function o = cumsum(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - o dseries object.
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -39,7 +39,7 @@ else
end
end
return
return % --*-- Unit tests --*--
%@test:1
% Define a data set.
......@@ -98,4 +98,4 @@ if t(1)
t(3) = dassert(ts1.data, A);
end
T = all(t);
%@eof:2
\ No newline at end of file
%@eof:2
function o = cumsum_(varargin) % --*-- Unitary tests --*--
function o = cumsum_(varargin)
% Overloads matlab's cumsum function for dseries objects.
%
......@@ -10,7 +10,7 @@ function o = cumsum_(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - o dseries object.
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -126,7 +126,7 @@ switch nargin
error('dseries::cumsum: Wrong number of input arguments!')
end
return
return % --*-- Unit tests --*--
%@test:1
% Define a data set.
......@@ -293,4 +293,4 @@ if t(1)
t(2) = dassert(ts0.data, A);
end
T = all(t);
%@eof:6
\ No newline at end of file
%@eof:6
function o = detrend(o, model) % --*-- Unitary tests --*--
function o = detrend(o, model)
% Detrends a dseries object with a polynomial of order model.
%
......@@ -9,7 +9,7 @@ function o = detrend(o, model) % --*-- Unitary tests --*--
% OUTPUTS
% - o [dseries] detrended time series.
% Copyright © 2014-2021 Dynare Team
% Copyright © 2014-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -34,7 +34,7 @@ end
o = copy(o);
o.detrend_(model);
return
return % --*-- Unit tests --*--
%@test:1
% Define a dataset.
......@@ -53,4 +53,4 @@ if t(1)
end
T = all(t);
%@eof:1
\ No newline at end of file
%@eof:1
function o = detrend_(o, model) % --*-- Unitary tests --*--
function o = detrend_(o, model)
% Detrends a dseries object with a polynomial of order model.
%
......@@ -9,7 +9,7 @@ function o = detrend_(o, model) % --*-- Unitary tests --*--
% OUTPUTS
% - o [dseries] detrended time series.
% Copyright © 2014-2021 Dynare Team
% Copyright © 2014-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -60,7 +60,7 @@ for i=1:vobs(o)
end
end
return
return % --*-- Unit tests --*--
%@test:1
% Define a dataset.
......@@ -146,4 +146,4 @@ if t(1)
end
T = all(t);
%@eof:2
\ No newline at end of file
%@eof:2
function o = dgrowth(o) % --*-- Unitary tests --*--
function o = dgrowth(o)
% Computes daily growth rates.
%
......@@ -8,7 +8,7 @@ function o = dgrowth(o) % --*-- Unitary tests --*--
% OUTPUTS
% - o [dseries]
% Copyright © 2020-2021 Dynare Team
% Copyright © 2020-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -28,7 +28,7 @@ function o = dgrowth(o) % --*-- Unitary tests --*--
o = copy(o);
o.dgrowth_();
return
return % --*-- Unit tests --*--
%@test:1
try
......@@ -48,4 +48,4 @@ if t(1)
end
T = all(t);
%@eof:1
\ No newline at end of file
%@eof:1
function o = dgrowth_(o) % --*-- Unitary tests --*--
function o = dgrowth_(o)
% Computes daily growth rates.
%
......@@ -8,7 +8,7 @@ function o = dgrowth_(o) % --*-- Unitary tests --*--
% OUTPUTS
% - o [dseries]
% Copyright © 2020-2021 Dynare Team
% Copyright © 2020-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -35,7 +35,7 @@ switch frequency(o)
case 12
error('dseries::dgrowth: I cannot compute daily growth rates from monthly data!')
case 52
error('dseries::dgrowth: I cannot compute daily growth rates from weekly data!')
error('dseries::dgrowth: I cannot compute daily growth rates from weekly data!')
case 365
o.data(2:end,:) = o.data(2:end,:)./o.data(1:end-1,:) - 1;
o.data(1,:) = NaN;
......@@ -51,7 +51,7 @@ for i = 1:vobs(o)
end
end
return
return % --*-- Unit tests --*--
%@test:1
try
......
function o = diff(o) % --*-- Unitary tests --*--
function o = diff(o)
% Computes differences.
%
......@@ -8,7 +8,7 @@ function o = diff(o) % --*-- Unitary tests --*--
% OUTPUTS
% - o [dseries]
% Copyright © 2017-2021 Dynare Team
% Copyright © 2017-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -28,7 +28,7 @@ function o = diff(o) % --*-- Unitary tests --*--
o = copy(o);
o.diff_();
return
return % --*-- Unit tests --*--
%@test:1
try
......@@ -48,4 +48,4 @@ if t(1)
end
T = all(t);
%@eof:1
\ No newline at end of file
%@eof:1
function o = diff_(o) % --*-- Unitary tests --*--
function o = diff_(o)
% Computes differences, independently of the frequency.
%
......@@ -8,7 +8,7 @@ function o = diff_(o) % --*-- Unitary tests --*--
% OUTPUTS
% - o [dseries]
% Copyright © 2017-2021 Dynare Team
% Copyright © 2017-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -36,7 +36,7 @@ for i = 1:vobs(o)
end
end
return
return % --*-- Unit tests --*--
%@test:1
try
......@@ -55,4 +55,4 @@ if t(1)
end
T = all(t);
%@eof:1
\ No newline at end of file
%@eof:1
function disp(o)
function disp(o, noname)
% Overloads disp method.
%
% INPUTS
% - o [dseries] Object to be displayed.
% - o [dseries] Object to be displayed.
% - noname [logical] Do not display the name of the dseries object if true. Default is false.
%
% OUTPUTS
% None
% Copyright (C) 2011-2017 Dynare Team
% Copyright © 2011-2024 Dynare Team
%
% This file is part of Dynare.
%
......@@ -25,6 +26,10 @@ function disp(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if nargin<2
nonname = false;
end
vspace = ' ';
if ~vobs(o)
......@@ -35,9 +40,11 @@ end
separator = repmat(' | ', nobs(o)+1,1);
TABLE = ' ';
for t=1:nobs(o)
TABLE = char(TABLE, date2string(o.dates(t)));
end
for i = 1:vobs(o)
TABLE = horzcat(TABLE,separator);
tmp = o.name{i};
......@@ -46,8 +53,13 @@ for i = 1:vobs(o)
end
TABLE = horzcat(TABLE, tmp);
end
disp(vspace)
disp([inputname(1) ' is a dseries object:'])
disp(vspace);
if ~noname
disp([inputname(1) ' is a dseries object:'])
disp(vspace);
end
disp(TABLE);
disp(vspace);
\ No newline at end of file
disp(vspace);
......@@ -12,7 +12,7 @@ function display(o)
% Contray to the disp method, the whole dseries object is not displayed if the number of
% observations is greater than 40 and if the number of variables is greater than 10.
% Copyright (C) 2011-2017 Dynare Team
% Copyright © 2011-2017 Dynare Team
%
% This file is part of Dynare.
%
......
classdef dseries<handle % --*-- Unitary tests --*--
classdef dseries<handle
% Class for time series.
% Copyright (C) 2013-2021 Dynare Team
% Copyright © 2013-2023 Dynare Team
%
% This code is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
......@@ -178,7 +178,7 @@ methods
end
end % dseries
end % methods
end % classdef
end % classdef --*-- Unit tests --*--
%@test:1
%$ % Test if we can instantiate an empty dseries object.
......
......@@ -10,7 +10,7 @@ function lastIndex = end(o, k, n)
% OUTPUTS
% - lastIndex [integer]
% Copyright (C) 2014-2017 Dynare Team
% Copyright © 2014-2017 Dynare Team
%
% This file is part of Dynare.
%
......
function b = eq(o, p) % --*-- Unitary tests --*--
function b = eq(o, p)
% Overloads eq (==) operator.
%
......@@ -12,7 +12,7 @@ function b = eq(o, p) % --*-- Unitary tests --*--
% REMARKS
% If the number of variables, the number of observations or the frequencies are different in A and B, the function returns a zero scalar.
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2023 Dynare Team
%
% This file is part of Dynare.
%
......@@ -63,7 +63,7 @@ end
b = eq(o.data, p.data);
return
return % --*-- Unit tests --*--
%@test:1
% Define a datasets.
......@@ -85,7 +85,7 @@ catch
end
if length(t)>1
t(2) = dassert(a,logical(ones(10,3)));
t(2) = dassert(a,true(10,3));
end
T = all(t);
%@eof:1
\ No newline at end of file
%@eof:1