From 399ab297dab7a21668df0357f9471bfcdbbe4c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Sat, 6 Dec 2014 22:53:55 +0100 Subject: [PATCH] Rewrote unique function. --- src/@dates/unique.m | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/@dates/unique.m b/src/@dates/unique.m index e655b51..1d74432 100644 --- a/src/@dates/unique.m +++ b/src/@dates/unique.m @@ -1,23 +1,24 @@ -function B = unique(A) % --*-- Unitary tests --*-- +function o = unique(o) % --*-- Unitary tests --*-- % Overloads the unique function for dates objects. % % INPUTS -% o A dates object. +% - o [dates] % -% OUTPUTS -% o B dates object (a copy of A without repetitions, only the last occurence of a date is kept). - -% Copyright (C) 2012-2013 Dynare Team +% OUPUTS +% - o [dates] % -% This file is part of Dynare. +% REMARKS +% 1. Only the last occurence of a date is kept. + +% Copyright (C) 2013-2014 Dynare Team % -% Dynare is free software: you can redistribute it and/or modify +% 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 % the Free Software Foundation, either version 3 of the License, or % (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 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. @@ -25,20 +26,18 @@ function B = unique(A) % --*-- Unitary tests --*-- % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -if isequal(A.ndat,1) +if o.ndat<=1 return end -B = A; - if isoctave || matlab_ver_less_than('8.1.0') - [tmp, id, jd] = unique(A.time,'rows'); + [tmp, id, jd] = unique(o.time,'rows'); else - [tmp, id, jd] = unique(A.time,'rows','legacy'); + [tmp, id, jd] = unique(o.time,'rows','legacy'); end -B.time = A.time(sort(id),:); -B.ndat = size(B.time,1); +o.time = o.time(sort(id),:); +o.ndat = size(o.time,1); %@test:1 %$ % Define some dates -- GitLab