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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
dseries
Commits
5c819330
Commit
5c819330
authored
10 years ago
by
Stéphane Adjemian
Browse files
Options
Downloads
Patches
Plain Diff
Added remove method.
parent
94029c54
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/@dates/remove.m
+80
-0
80 additions, 0 deletions
src/@dates/remove.m
src/@dates/subsref.m
+1
-1
1 addition, 1 deletion
src/@dates/subsref.m
with
81 additions
and
1 deletion
src/@dates/remove.m
0 → 100644
+
80
−
0
View file @
5c819330
function
o
=
remove
(
o
,
p
)
% --*-- Unitary tests --*--
% remove method for dates class (removes dates).
%
% INPUTS
% - o [dates]
% - p [dates]
%
% OUTPUTS
% - o [dates]
%
% REMARKS
% 1. If a is a date appearing more than once in o, then all occurences are removed.
% 2. The removal of p is done by inplace modification of o (in place version of setdiff).
%
% See also pop, setdiff
% Copyright (C) 2013-2014 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
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% 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.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if
nargin
<
2
error
(
'dates:remove'
,
'Input argument is missing! You should read the manual'
)
end
if
~
isdates
(
p
)
error
(
'dates:remove'
,
'Input argument %s has to be a dates object'
)
end
if
~
isequal
(
o
.
freq
,
p
.
freq
)
error
(
'dates:remove'
,
'Inputs must have common frequency!'
)
end
if
isoctave
||
matlab_ver_less_than
(
'8.1.0'
)
time
=
setdiff
(
o
.
time
,
p
.
time
,
'rows'
);
else
time
=
setdiff
(
o
.
time
,
p
.
time
,
'rows'
,
'legacy'
);
end
o
.
time
=
time
;
o
.
ndat
=
rows
(
time
);
%@test:1
%$ % Define some dates objects
%$ d = dates('1950Q1'):dates('1952Q4');
%$ e = dates('1951Q1'):dates('1952Q4');
%$ f = dates('1950Q1'):dates('1950Q4');
%$
%$ % Call the tested routine.
%$ d.remove(e);
%$
%$ % Check the results.
%$ t(1) = dassert(d,f);
%$ T = all(t);
%@eof:1
%@test:2
%$ % Define some dates objects
%$ d = dates('1950Q1','1950Q2','1950Q1');
%$ e = dates('1950Q1');
%$ f = dates('1950Q2');
%$
%$ % Call the tested routine.
%$ d.remove(e);
%$
%$ % Check the results.
%$ t(1) = dassert(d,f);
%$ T = all(t);
%@eof:2
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/@dates/subsref.m
+
1
−
1
View file @
5c819330
...
...
@@ -42,7 +42,7 @@ switch S(1).type
if
length
(
S
)
>
1
&&
isequal
(
S
(
2
)
.
type
,
'()'
)
&&
isempty
(
S
(
2
)
.
subs
)
S
=
shiftS
(
S
,
1
);
end
case
{
'append'
,
'pop'
}
% Public methods (with arguments).
case
{
'append'
,
'pop'
,
'remove'
}
% Public methods (with arguments).
if
isequal
(
S
(
2
)
.
type
,
'()'
)
B
=
feval
(
S
(
1
)
.
subs
,
A
,
S
(
2
)
.
subs
{:});
S
=
shiftS
(
S
,
1
);
...
...
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