Skip to content
Snippets Groups Projects
Verified Commit 11e9e608 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Compatibility fixes for Octave 6

parent af4d2cc3
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,8 @@ if ~isequal(o.freq,p.freq)
return
end
% Octave 6.1.0 added support for the 'legacy' option, but we don't use it
% because of this bug: https://savannah.gnu.org/bugs/?59708
if isoctave
time = intersect(o.time,p.time,'rows');
else
......
......@@ -42,7 +42,7 @@ if ~isequal(o.freq,p.freq)
error('dates:remove','Inputs must have common frequency!')
end
if isoctave
if isoctave && octave_ver_less_than('6')
time = setdiff(o.time,p.time,'rows');
else
time = setdiff(o.time,p.time,'rows','legacy');
......
......@@ -48,7 +48,7 @@ if isequal(o.length(),p.length()) && isequal(o, p)
return
end
if isoctave
if isoctave && octave_ver_less_than('6')
if nargout<2
time = setdiff(o.time,p.time,'rows');
else
......
......@@ -30,7 +30,7 @@ if o.ndat()<=1
return
end
if isoctave
if isoctave && octave_ver_less_than('6')
[tmp, id, jd] = unique(o.time,'rows');
else
[tmp, id, jd] = unique(o.time,'rows','legacy');
......
......@@ -56,6 +56,10 @@ if ~exist('matlab_ver_less_than','file')
p{end+1} = 'utilities/missing/matlab_ver_less_than';
end
if ~exist('octave_ver_less_than','file')
p{end+1} = 'utilities/missing/octave_ver_less_than';
end
if ~exist('demean','file')
p{end+1} = 'utilities/missing/demean';
end
......
......@@ -29,7 +29,7 @@ end
ds = dseries();
% Check for multiple datasets
if isoctave()
if isoctave && octave_ver_less_than('6')
dataset_codes = unique(o.data(:,o.col_idx.dataset_code));
else
dataset_codes = unique(o.data(:,o.col_idx.dataset_code),'stable');
......@@ -39,7 +39,7 @@ end
for ii = 1:length(dataset_codes)
% Slice data for dataset
ds_dataset = o.data(strcmp(o.data(:,o.col_idx.dataset_code),dataset_codes{ii}),:);
if isoctave()
if isoctave && octave_ver_less_than('6')
series_codes = unique(ds_dataset(:,o.col_idx.series_code));
else
series_codes = unique(ds_dataset(:,o.col_idx.series_code),'stable');
......@@ -90,7 +90,7 @@ end
% Add tags to the variables
if length(dataset_codes) > 1
if isoctave()
if isoctave && octave_ver_less_than('6')
series_codes = unique(o.data(:,o.col_idx.series_code));
else
series_codes = unique(o.data(:,o.col_idx.series_code),'stable');
......
function r = octave_ver_less_than(verstr)
% function r = octave_ver_less_than(verstr)
%
% Returns 1 if current Octave version is strictly older than
% the one given in argument.
%
% Note that this function will fail under Matlab.
%
% INPUTS
% verstr: a string of the format 'x.y' or 'x.y.z'
%
% OUTPUTS
% r: 0 or 1
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2008-2019 Dynare Team
%
% This file is part of Dynare.
%
% Dynare 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,
% 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/>.
r = compare_versions(version(), verstr, "<");
endfunction
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment