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 160 additions and 155 deletions
function l = isempty(o) % --*-- Unitary tests --*--
function l = isempty(o)
% Returns true (1) if and only if o dates object is empty.
%
......@@ -8,7 +8,7 @@ function l = isempty(o) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical]
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -25,7 +25,7 @@ function l = isempty(o) % --*-- Unitary tests --*--
l = isequal(o.ndat(), 0);
return
return % --*-- Unit tests --*--
%@test:1
% Instantiate an empty dates object
......
function l = isequal(o, p, fake) % --*-- Unitary tests --*--
function l = isequal(o, p, fake)
% Overloads isequal function for dates objects. Returns true true iff o and p have the same elements.
%
......@@ -9,7 +9,7 @@ function l = isequal(o, p, fake) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical]
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -30,7 +30,7 @@ end
l = isequal(o.freq, p.freq) && isequal(o.time, p.time);
return
return % --*-- Unit tests --*--
%@test:1
d1 = dates('1938Q1');
......
function l = le(varargin) % --*-- Unitary tests --*--
function l = le(varargin)
% Overloads the <= operator for dates objects.
%
......@@ -9,7 +9,7 @@ function l = le(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical] column vector of max(n,1) elements (zeros or ones).
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -28,7 +28,7 @@ function l = le(varargin) % --*-- Unitary tests --*--
l = o.time<=p.time;
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates
......
function n = length(o) % --*-- Unitary tests --*--
function n = length(o)
% Returns the number of elements in a dates object.
%
......@@ -8,7 +8,7 @@ function n = length(o) % --*-- Unitary tests --*--
% OUTPUTS
% - n [integer] Number of elements in o.
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -25,7 +25,7 @@ function n = length(o) % --*-- Unitary tests --*--
n = o.ndat();
return
return % --*-- Unit tests --*--
%@test:1
d = dates('1938Q1');
......
function l = lt(varargin) % --*-- Unitary tests --*--
function l = lt(varargin)
% Overloads the < operator for dates objects.
%
......@@ -9,7 +9,7 @@ function l = lt(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical] column vector of max(n,1) elements (zeros or ones).
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -28,7 +28,7 @@ function l = lt(varargin) % --*-- Unitary tests --*--
l = o.time<p.time;
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates
......
function q = max(varargin) % --*-- Unitary tests --*--
function q = max(varargin)
% Overloads the max function for dates objects.
%
......@@ -8,7 +8,7 @@ function q = max(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - q [dates]
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -36,7 +36,7 @@ switch nargin
q = max(horzcat(varargin{:}));
end
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates
......
function q = min(varargin) % --*-- Unitary tests --*--
function q = min(varargin)
% Overloads the min function for dates objects.
%
......@@ -8,7 +8,7 @@ function q = min(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - q [dates]
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -36,7 +36,7 @@ switch nargin
q = min(horzcat(varargin{:}));
end
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates
......
function q = minus(o,p) % --*-- Unitary tests --*--
function q = minus(o,p)
% Overloads the minus operator (-). If o and p are dates objects, the method . If
% one of the inputs is an integer or a vector of integers, the method shifts the dates object by X (the interger input) periods backward.
......@@ -18,7 +18,7 @@ function q = minus(o,p) % --*-- Unitary tests --*--
% p periods backward.
% 3. If o is not a dates object, an error is returned.
% Copyright © 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
......@@ -68,7 +68,7 @@ else
error('dates:minus:ArgCheck', 'You should read the manual.')
end
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates objects
......
function p = mtimes(o,n) % --*-- Unitary tests --*--
function p = mtimes(o,n)
% Overloads the times operator (*). Returns dates object o replicated n times.
%
......@@ -12,7 +12,7 @@ function p = mtimes(o,n) % --*-- Unitary tests --*--
% 1. If A = dates('2000Q1'), then B=A*3 is a dates object equal to dates('2000Q1','2000Q1','2000Q1')
% 2. If A = dates('2003Q1','2009Q2'), then B=A*2 is a dates object equal to dates('2003Q1','2009Q2','2003Q1','2009Q2')
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -34,7 +34,7 @@ end
p = copy(o);
p.time = repmat(p.time, n, 1);
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates
......
function s = ndat(o) % --*-- Unitary tests --*--
function s = ndat(o)
% Given a one element dates object, returns a string with the formatted date.
% Returns the number of element in a dates object.
%
% INPUTS
% - o [dates]
%
% OUTPUTS
% - s [integer]
%
% REMARKS
% This method is deprecated, use length() instead
% Copyright © 2015-2021 Dynare Team
% Copyright © 2015-2024 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
......@@ -25,7 +28,7 @@ function s = ndat(o) % --*-- Unitary tests --*--
s = length(o.time);
return
return % --*-- Unit tests --*--
%@test:1
% Define a dates object
......@@ -79,4 +82,4 @@ if t(1)
t(2) = dassert(card,10);
end
T = all(t);
%@eof:3
\ No newline at end of file
%@eof:3
function l = ne(varargin) % --*-- Unitary tests --*--
function l = ne(varargin)
% Overloads ~= operator for dates objects.
%
......@@ -9,7 +9,7 @@ function l = ne(varargin) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical] column vector of max(n,1) elements (zeros or ones).
% Copyright © 2013-2020 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
......@@ -28,7 +28,7 @@ function l = ne(varargin) % --*-- Unitary tests --*--
l = o.time~=p.time;
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates objects
......
function q = plus(o, p) % --*-- Unitary tests --*--
function q = plus(o, p)
% Overloads the plus (+) binary operator.
%
......@@ -14,7 +14,7 @@ function q = plus(o, p) % --*-- Unitary tests --*--
% 2. If one of the inputs is an integer or a vector of integers, the method shifts the dates
% object by X (the interger input) periods forward.
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -65,7 +65,7 @@ else
error('dates:plus:ArgCheck','Please read the manual.')
end
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates objects
......
function o = pop(o, p) % --*-- Unitary tests --*--
function o = pop(o, p)
% pop method for dates class (removes a date).
%
......@@ -15,7 +15,7 @@ function o = pop(o, p) % --*-- Unitary tests --*--
%
% See also remove, setdiff.
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -38,7 +38,7 @@ else
o.pop_();
end
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates
......
function o = pop_(o, p) % --*-- Unitary tests --*--
function o = pop_(o, p)
% pop method for dates class (in place modification).
%
......@@ -15,7 +15,7 @@ function o = pop_(o, p) % --*-- Unitary tests --*--
%
% See also remove, setdiff.
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -66,7 +66,7 @@ else
o.time = o.time(jdx);
end
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates
......
function [o, p] = comparison_arg_checks(varargin) % --*-- Unitary tests --*--
function [o, p] = comparison_arg_checks(varargin)
% Returns two dates objects or an error if objects to be compared are not compatible.
%
......@@ -9,7 +9,7 @@ function [o, p] = comparison_arg_checks(varargin) % --*-- Unitary tests --*--
% - o [dates] dates object with n or 1 elements.
% - p [dates] dates object with n or 1 elements.
% Copyright © 2014-2021 Dynare Team
% Copyright © 2014-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
......@@ -49,7 +49,7 @@ end
o = varargin{1};
p = varargin{2};
return
return % --*-- Unit tests --*--
%@test:1
OPATH = pwd();
......@@ -166,4 +166,4 @@ end
T = all(t);
cd(OPATH);
%@eof:7
\ No newline at end of file
%@eof:7
function str = dates4display(o, name, max_number_of_elements) % --*-- Unitary tests --*--
function str = dates4display(o, name, max_number_of_elements)
% Converts a list object to a string.
%
......@@ -10,7 +10,7 @@ function str = dates4display(o, name, max_number_of_elements) % --*-- Unitary te
% OUTPUTS
% - str [string] Representation of the dates object as a string.
% Copyright (C) 2014-2021 Dynare Team
% Copyright © 2014-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
......@@ -47,106 +47,108 @@ else
end
str = sprintf('%s%s>\n', str, date2string(o.time(o.length()), o.freq));
return % --*-- Unit tests --*--
%@test:1
%$ OPATH = pwd();
%$ DSERIES_PATH = strrep(which('initialize_dseries_class'),'/initialize_dseries_class.m','');
%$ cd([DSERIES_PATH '/@dates/private']);
%$
%$ try
%$ toto = dates();
%$ str = dates4display(toto, 'toto', 5);
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ if t(1)
%$ expected_str_1 = sprintf('toto is an empty dates object.\\n');
%$ try
%$ t(2) = dassert(str, expected_str_1);
%$ catch
%$ t(2) = false;
%$ end
%$ end
%$
%$ T = all(t);
%$ cd(OPATH);
OPATH = pwd();
DSERIES_PATH = strrep(which('initialize_dseries_class'),'/initialize_dseries_class.m','');
cd([DSERIES_PATH '/@dates/private']);
try
toto = dates();
str = dates4display(toto, 'toto', 5);
t(1) = true;
catch
t(1) = false;
end
if t(1)
expected_str_1 = sprintf('toto is an empty dates object.\\n');
try
t(2) = dassert(str, expected_str_1);
catch
t(2) = false;
end
end
T = all(t);
cd(OPATH);
%@eof:1
%@test:2
%$ OPATH = pwd();
%$ DSERIES_PATH = strrep(which('initialize_dseries_class'),'/initialize_dseries_class.m','');
%$ cd([DSERIES_PATH '/@dates/private']);
%$
%$ try
%$ toto = dates('1950Q1'):dates('1950Q2');
%$ str = dates4display(toto, 'toto', 5);
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ if t(1)
%$ expected_str_2 = sprintf('toto = <dates: 1950Q1, 1950Q2>\\n');
%$ try
%$ t(2) = dassert(str, expected_str_2);
%$ catch
%$ t(2) = false;
%$ end
%$ end
%$
%$ T = all(t);
%$ cd(OPATH);
OPATH = pwd();
DSERIES_PATH = strrep(which('initialize_dseries_class'),'/initialize_dseries_class.m','');
cd([DSERIES_PATH '/@dates/private']);
try
toto = dates('1950Q1'):dates('1950Q2');
str = dates4display(toto, 'toto', 5);
t(1) = true;
catch
t(1) = false;
end
if t(1)
expected_str_2 = sprintf('toto = <dates: 1950Q1, 1950Q2>\\n');
try
t(2) = dassert(str, expected_str_2);
catch
t(2) = false;
end
end
T = all(t);
cd(OPATH);
%@eof:2
%@test:3
%$ OPATH = pwd();
%$ DSERIES_PATH = strrep(which('initialize_dseries_class'),'/initialize_dseries_class.m','');
%$ cd([DSERIES_PATH '/@dates/private']);
%$
%$ try
%$ toto = dates('1950Q1'):dates('1951Q1');
%$ str = dates4display(toto, 'toto', 4);
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ if t(1)
%$ expected_str_3 = sprintf('toto = <dates: 1950Q1, 1950Q2, ..., 1950Q4, 1951Q1>\\n');
%$ try
%$ t(2) = dassert(str, expected_str_3);
%$ catch
%$ t(2) = false;
%$ end
%$ end
%$
%$ T = all(t);
%$ cd(OPATH);
OPATH = pwd();
DSERIES_PATH = strrep(which('initialize_dseries_class'),'/initialize_dseries_class.m','');
cd([DSERIES_PATH '/@dates/private']);
try
toto = dates('1950Q1'):dates('1951Q1');
str = dates4display(toto, 'toto', 4);
t(1) = true;
catch
t(1) = false;
end
if t(1)
expected_str_3 = sprintf('toto = <dates: 1950Q1, 1950Q2, ..., 1950Q4, 1951Q1>\\n');
try
t(2) = dassert(str, expected_str_3);
catch
t(2) = false;
end
end
T = all(t);
cd(OPATH);
%@eof:3
%@test:4
%$ OPATH = pwd();
%$ DSERIES_PATH = strrep(which('initialize_dseries_class'),'/initialize_dseries_class.m','');
%$ cd([DSERIES_PATH '/@dates/private']);
%$
%$ try
%$ toto = dates('1950Q1'):dates('1951Q1');
%$ str = dates4display(toto, 'toto', 6);
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ if t(1)
%$ expected_str_4 = sprintf('toto = <dates: 1950Q1, 1950Q2, 1950Q3, 1950Q4, 1951Q1>\\n');
%$ try
%$ t(2) = dassert(str, expected_str_4);
%$ catch
%$ t(2) = false;
%$ end
%$ end
%$
%$ T = all(t);
%$ cd(OPATH);
OPATH = pwd();
DSERIES_PATH = strrep(which('initialize_dseries_class'),'/initialize_dseries_class.m','');
cd([DSERIES_PATH '/@dates/private']);
try
toto = dates('1950Q1'):dates('1951Q1');
str = dates4display(toto, 'toto', 6);
t(1) = true;
catch
t(1) = false;
end
if t(1)
expected_str_4 = sprintf('toto = <dates: 1950Q1, 1950Q2, 1950Q3, 1950Q4, 1951Q1>\\n');
try
t(2) = dassert(str, expected_str_4);
catch
t(2) = false;
end
end
T = all(t);
cd(OPATH);
%@eof:4
function o = remove(o, p) % --*-- Unitary tests --*--
function o = remove(o, p)
% remove method for dates class (removes dates).
%
......@@ -15,7 +15,7 @@ function o = remove(o, p) % --*-- Unitary tests --*--
%
% See also pop, setdiff
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -45,7 +45,7 @@ end
o = copy(o);
o.remove_(p);
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates objects
......
function o = remove_(o, p) % --*-- Unitary tests --*--
function o = remove_(o, p)
% remove method for dates class (removes dates).
%
......@@ -15,7 +15,7 @@ function o = remove_(o, p) % --*-- Unitary tests --*--
%
% See also pop, setdiff
% Copyright © 2013-2021 Dynare Team
% Copyright © 2013-2022 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
......@@ -46,7 +46,7 @@ time = setdiff(o.time, p.time, 'legacy');
o.time = time;
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates objects
......
function [q, io] = setdiff(o, p) % --*-- Unitary tests --*--
function [q, io] = setdiff(o, p)
% Overloads setdiff function for dates objects.
%
......@@ -12,7 +12,7 @@ function [q, io] = setdiff(o, p) % --*-- Unitary tests --*--
%
% See also pop, remove.
% Copyright © 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
......@@ -27,7 +27,7 @@ function [q, io] = setdiff(o, p) % --*-- Unitary tests --*--
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if ~isa(o, 'dates') || ~isa(o, 'dates')
if ~isa(o, 'dates') || ~isa(p, 'dates')
error('dates:setdiff', 'All input arguments must be dates objects.')
end
......@@ -57,7 +57,7 @@ end
q = dates(o.freq);
q.time = time;
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates objects
......
function o = sort(o) % --*-- Unitary tests --*--
function o = sort(o)
% Sort method for dates class (with copy).
%
......@@ -8,7 +8,7 @@ function o = sort(o) % --*-- Unitary tests --*--
% OUTPUTS
% - o [dates] with dates sorted by increasing order.
% Copyright © 2011-2021 Dynare Team
% Copyright © 2011-2022 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
......@@ -26,7 +26,7 @@ function o = sort(o) % --*-- Unitary tests --*--
o = copy(o);
o.sort_();
return
return % --*-- Unit tests --*--
%@test:1
% Define some dates
......