Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dseries
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sébastien Villemot
dseries
Commits
b8ecec74
Commit
b8ecec74
authored
Dec 6, 2014
by
Stéphane Adjemian
Browse files
Options
Downloads
Patches
Plain Diff
Rewrote min function and fixed unit tests.
parent
2b2b6f19
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/@dates/min.m
+26
-25
26 additions, 25 deletions
src/@dates/min.m
with
26 additions
and
25 deletions
src/@dates/min.m
+
26
−
25
View file @
b8ecec74
function
C
=
min
(
varargin
)
function
q
=
min
(
varargin
)
% --*-- Unitary tests --*--
% Overloads the min function for dates objects.
% Overloads the min function for dates objects.
% Copyright (C) 2013 Dynare Team
%
%
% This file is part of Dynare.
% INPUTS
% - varargin [dates]
%
% OUTPUTS
% - q [dates]
% Copyright (C) 2013-2014 Dynare Team
%
%
%
Dynar
e is free software: you can redistribute it and/or modify
%
This cod
e is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
% (at your option) any later version.
%
%
% Dynare is distributed in the hope that it will be useful,
% Dynare
dates submodule
is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
% GNU General Public License for more details.
...
@@ -19,22 +23,19 @@ function C = min(varargin)
...
@@ -19,22 +23,19 @@ function C = min(varargin)
% You should have received a copy of the GNU General Public License
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if
~
all
(
cellfun
(
@
isdates
,
varargin
))
error
(
'dates:min:ArgCheck'
,
'All input arguments must be dates objects.'
)
end
switch
nargin
switch
nargin
case
1
case
1
switch
length
(
varargin
{
1
})
sorted_time_member
=
sortrows
(
varargin
{
1
}
.
time
);
case
0
q
=
dates
();
C
=
dates
();
q
.
freq
=
varargin
{
1
}
.
freq
;
case
1
q
.
ndat
=
1
;
C
=
varargin
{
1
};
q
.
time
=
sorted_time_member
(
1
,:);
otherwise
tmp
=
sortrows
(
varargin
{
1
}
.
time
);
C
=
dates
();
C
.
freq
=
varargin
{
1
}
.
freq
;
C
.
ndat
=
1
;
C
.
time
=
tmp
(
1
,:);
end
otherwise
otherwise
C
=
min
(
horzcat
(
varargin
{:}));
q
=
min
(
horzcat
(
varargin
{:}));
end
end
%@test:1
%@test:1
...
@@ -49,8 +50,8 @@ end
...
@@ -49,8 +50,8 @@ end
%$ i3 = (m3==d6);
%$ i3 = (m3==d6);
%$
%$
%$ % Check the results.
%$ % Check the results.
%$ t(1) = dassert(i2,
1
);
%$ t(1) = dassert(i2,
true
);
%$ t(2) = dassert(i3,
1
);
%$ t(2) = dassert(i3,
true
);
%$ T = all(t);
%$ T = all(t);
%@eof:1
%@eof:1
...
@@ -61,7 +62,7 @@ end
...
@@ -61,7 +62,7 @@ end
%$ i = (m==dates('1949Q1'));
%$ i = (m==dates('1949Q1'));
%$
%$
%$ % Check the results.
%$ % Check the results.
%$ t(1) = dassert(i,
1
);
%$ t(1) = dassert(i,
true
);
%$ T = all(t);
%$ T = all(t);
%@eof:2
%@eof:2
...
@@ -71,7 +72,7 @@ end
...
@@ -71,7 +72,7 @@ end
%$ i = (m==dates('1949Q1'));
%$ i = (m==dates('1949Q1'));
%$
%$
%$ % Check the results.
%$ % Check the results.
%$ t(1) = dassert(i,
1
);
%$ t(1) = dassert(i,
true
);
%$ T = all(t);
%$ T = all(t);
%@eof:3
%@eof:3
...
@@ -81,6 +82,6 @@ end
...
@@ -81,6 +82,6 @@ end
%$ i = (m==dates('1949Q1'));
%$ i = (m==dates('1949Q1'));
%$
%$
%$ % Check the results.
%$ % Check the results.
%$ t(1) = dassert(i,
1
);
%$ t(1) = dassert(i,
true
);
%$ T = all(t);
%$ T = all(t);
%@eof:4
%@eof:4
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment