...
 
Commits (7)
...@@ -5,23 +5,21 @@ variables: ...@@ -5,23 +5,21 @@ variables:
before_script: before_script:
- git clone https://git.dynare.org/Dynare/m-unit-tests - git clone https://git.dynare.org/Dynare/m-unit-tests
testsuite_matlab: test_matlab:
stage: test stage: test
script: script:
- make check-matlab - make check-matlab
testsuite_old_matlab: test_old_matlab:
stage: test stage: test
variables: variables:
MATLAB: /usr/local/MATLAB/R2009b/bin/matlab MATLAB: /usr/local/MATLAB/R2009b/bin/matlab
script: script:
- make check-matlab - make check-matlab
allow_failure: true
testsuite_octave: test_octave:
stage: test stage: test
variables: variables:
OPENBLAS_NUM_THREADS: 1 OPENBLAS_NUM_THREADS: 1
script: script:
- make check-octave - make check-octave
allow_failure: true
> Copyright (C) 2014-2018 Dynare Team > Copyright (C) 2014-2018 Dynare Team
> >
> The dseries and dates Matlab/Octave classes are licensed under GNU GPL as published by > The dseries and dates MATLAB/Octave classes are licensed under GNU GPL as published by
> the Free Software Foundation, either version 3 of the License, or (at > the Free Software Foundation, either version 3 of the License, or (at
> your option) any later version. > your option) any later version.
> >
......
[![pipeline status](https://git.dynare.org/Dynare/dseries/badges/master/pipeline.svg)](https://git.dynare.org/Dynare/dseries/commits/master) [![pipeline status](https://git.dynare.org/Dynare/dseries/badges/master/pipeline.svg)](https://git.dynare.org/Dynare/dseries/commits/master)
This Matlab/Octave toolbox comes with two classes: This MATLAB/Octave toolbox comes with two classes:
- `@dates` which is used to handle dates. - `@dates` which is used to handle dates.
- `@dseries` which is used to handle time series data. - `@dseries` which is used to handle time series data.
...@@ -8,7 +8,7 @@ This Matlab/Octave toolbox comes with two classes: ...@@ -8,7 +8,7 @@ This Matlab/Octave toolbox comes with two classes:
The package is a dependence of The package is a dependence of
[Dynare](https=//git.dynare.org/Dynare/dynare), but can also be used [Dynare](https=//git.dynare.org/Dynare/dynare), but can also be used
as a standalone package without Dynare. The package is as a standalone package without Dynare. The package is
compatible with Matlab 2008a and following versions, and (almost compatible with MATLAB 2008a and following versions, and (almost
compatible with) the latest Octave version. compatible with) the latest Octave version.
## Installation ## Installation
...@@ -25,30 +25,24 @@ or downloading a zip archive: ...@@ -25,30 +25,24 @@ or downloading a zip archive:
## Usage ## Usage
Add the `dseries/src` folder to the Matlab/Octave path, and run the following command (on Matlab/Octave) prompt: Add the `dseries/src` folder to the MATLAB/Octave path, and run the following command (on MATLAB/Octave) prompt:
>> dseries().initialize() >> dseries().initialize()
which, depending on your system, will add the necessary subfolders to which, depending on your system, will add the necessary subfolders to
the Matlab/Octave path. Also, if the MATLAB/Octave path.
[X13-ARIMA-SEATS](https://www.census.gov/srd/www/x13as/) is not
installed in your system (on debian it is possible to install it with
the `apt-get`) you will need (only the first time) to install the
binary. Scripts are available to install (or update) this
dependency. From the Matlab/Octave prompt:
>> cd dseries/externals/x13 You are then ready to go. A full documentation will come soon,
>> installx13()
and run the configuration again:
>> dseries.initialize()
You should not see the warning related to the missing `x13as`
binary. You are then ready to go. A full documentation will come soon,
but you can already obtain a general idea by looking into the Dynare but you can already obtain a general idea by looking into the Dynare
reference manual. reference manual.
Note that [X13-ARIMA-SEATS](https://www.census.gov/srd/www/x13as/) is required
for accessing all the features of the toolbox. On Windows and macOS, an
X13-ARIMA-SEATS binary is included in standalone dseries packages and in Dynare
packages. On Debian and Ubuntu it is possible to install X13-ARIMA-SEATS with
`apt install x13as` (on Debian, you must have the non-free archive area listed
in package sources).
## Examples ## Examples
### Instantiate a dseries object from an array ### Instantiate a dseries object from an array
......
x13.zip
linux/*
windows/*
*~
function installx13()
% Installs CENSUS X13 binaries (Windows and Linux).
% Copyright (C) 2017-2018 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 dseries 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 ~exist('x13.zip','file')
if ( ~isoctave() && verLessThan('matlab', 'R2014b') )
websave('x13.zip', 'https://www.dynare.org/x13/x13.zip');
else
urlwrite('https://www.dynare.org/x13/x13.zip', 'x13.zip');
end
unzip('x13.zip');
if ismac()
if exist('./osx', 'dir')
rmdir('osx', 's')
end
mkdir osx;
movefile('binaries/osx/*','./osx');
elseif isunix()
if exist('./linux', 'dir')
rmdir('linux', 's')
end
mkdir linux;
movefile('binaries/linux/*','./linux');
elseif ispc()
if exist('./windows', 'dir')
rmdir('windows', 's')
end
mkdir windows;
movefile('binaries/windows/*','./windows');
else
error('X13 is not available for the current platform!')
end
rmdir('binaries', 's');
end
function uninstallx13()
% Uninstalls CENSUS X13 binaries (Windows, OSX and Linux).
% Copyright (C) 2017 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 dseries 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 exist('x13.zip','file')
delete('x13.zip')
end
if exist('linux','dir')
rmdir('linux', 's')
end
if exist('windows','dir')
rmdir('windows', 's')
end
if exist('osx','dir')
rmdir('osx', 's')
end
\ No newline at end of file
function updatex13()
% Uninstalls CENSUS X13 binaries (Windows, OSX and Linux).
% Copyright (C) 2017 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 dseries 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 exist('x13.zip','file')
delete('x13.zip')
end
if exist('./binaries', 'dir')
rmdir('binaries', 's');
end
installx13();
\ No newline at end of file
...@@ -64,7 +64,7 @@ for i=1:nargin-1 ...@@ -64,7 +64,7 @@ for i=1:nargin-1
end end
% Check that square brackets in regular expressions % Check that square brackets in regular expressions
if useregularexpression && ~usewildcardparameter && ~isequal(length(idBracket.open),length(idBracket.open)) if useregularexpression && ~usewildcardparameter && ~isequal(length(idBracket.open),length(idBracket.open))
error('dseries::extract: (Matlab/Octave''s regular expressions) Check opening and closing square brackets!') error('dseries::extract: (MATLAB/Octave''s regular expressions) Check opening and closing square brackets!')
end end
% Loops and regular expressions are not compatible % Loops and regular expressions are not compatible
if useregularexpression && useimplicitloops if useregularexpression && useimplicitloops
......
...@@ -45,7 +45,7 @@ switch length(S) ...@@ -45,7 +45,7 @@ switch length(S)
idBracket.open = strfind(element, '['); idBracket.open = strfind(element, '[');
idBracket.close = strfind(element, ']'); idBracket.close = strfind(element, ']');
if ~isequal(length(idBracket.open),length(idBracket.open)) if ~isequal(length(idBracket.open),length(idBracket.open))
error('dseries::subsasgn: (Matlab/Octave''s regular expressions) Check opening and closing square brackets!') error('dseries::subsasgn: (MATLAB/Octave''s regular expressions) Check opening and closing square brackets!')
end end
% Loops and regular expressions are not compatible % Loops and regular expressions are not compatible
if length(idArobase) && length(idBracket.open) if length(idArobase) && length(idBracket.open)
......
...@@ -18,28 +18,6 @@ function initialize_dseries_class() ...@@ -18,28 +18,6 @@ function initialize_dseries_class()
% Get the path to the dseries toolbox. % Get the path to the dseries toolbox.
dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m',''); dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m','');
% Check that the x13 binary is available
nox13 = false;
if ismac()
if ~exist([dseries_src_root '../externals/x13/osx/64/x13as'], 'file')
nox13 = true;
end
elseif isunix()
[status, ~] = system('which x13as');
if status && ~(exist([dseries_src_root '../externals/x13/linux/64/x13as'], 'file') && exist([dseries_src_root '../externals/x13/linux/32/x13as'], 'file'))
nox13 = true;
end
elseif ispc()
if ~(exist([dseries_src_root '../externals/x13/windows/64/x13as.exe'], 'file') && exist([dseries_src_root '../externals/x13/windows/32/x13as.exe'], 'file'))
nox13 = true;
end
else
error('Unsupported platform.')
end
if nox13
warning('X13 binary is not available.\nIf you are under Debian or Ubuntu, you can install it through your package manager, with ''apt install x13as''.\nOtherwise, you can install it manually by running\nthe function installx13() available in:\n\n\t%s\n', [dseries_src_root(1:end-4), 'externals' filesep() 'x13']);
end
% Set the subfolders to be added in the path. % Set the subfolders to be added in the path.
p = {'read'; ... p = {'read'; ...
'utilities/is'; ... 'utilities/is'; ...
...@@ -54,11 +32,6 @@ p = {'read'; ... ...@@ -54,11 +32,6 @@ p = {'read'; ...
'utilities/cumulate'; ... 'utilities/cumulate'; ...
'utilities/struct'}; 'utilities/struct'};
% Add /utilities/x13' if x13 binary is available.
if ~nox13
p{end+1} = 'utilities/x13';
end
% Add missing routines if dynare is not in the path % Add missing routines if dynare is not in the path
if ~exist('isint','file') if ~exist('isint','file')
p{end+1} = 'utilities/missing/isint'; p{end+1} = 'utilities/missing/isint';
...@@ -112,15 +85,15 @@ if ~exist('one_sided_hp_filter','file') ...@@ -112,15 +85,15 @@ if ~exist('one_sided_hp_filter','file')
p{end+1} = 'utilities/missing/one_sided_hp_filter'; p{end+1} = 'utilities/missing/one_sided_hp_filter';
end end
if ~exist('OCTAVE_VERSION') && ~exist('ismatrix','file') if ~exist('OCTAVE_VERSION') && ~exist('ismatrix','builtin')
p{end+1} = 'utilities/missing/ismatrix'; p{end+1} = 'utilities/missing/ismatrix';
end end
if ~exist('OCTAVE_VERSION') && ~exist('isrow','file') if ~exist('OCTAVE_VERSION') && ~exist('isrow','builtin')
p{end+1} = 'utilities/missing/isrow'; p{end+1} = 'utilities/missing/isrow';
end end
if ~exist('OCTAVE_VERSION') && ~exist('iscolumn','file') if ~exist('OCTAVE_VERSION') && ~exist('iscolumn','builtin')
p{end+1} = 'utilities/missing/iscolumn'; p{end+1} = 'utilities/missing/iscolumn';
end end
...@@ -136,4 +109,11 @@ end ...@@ -136,4 +109,11 @@ end
P = cellfun(@(c)[dseries_src_root c], p, 'uni', false); P = cellfun(@(c)[dseries_src_root c], p, 'uni', false);
addpath(P{:}); addpath(P{:});
% If x13 binary is available, add corresponding utilities to the path.
% Otherwise, display a warning.
% This check can't be down before this point, because select_x13_binary requires is64bit
if ~isempty(select_x13_binary(true));
addpath([dseries_src_root 'utilities/x13']);
end
assignin('caller', 'dseries_src_root', dseries_src_root); assignin('caller', 'dseries_src_root', dseries_src_root);
function b = is64bit() function b = is64bit()
% Returns true iff Matlab 64bit version is used. % Returns true iff operating system is 64-bit
%
% The test logic is the same as in dynare.m when selecting the preprocessor
% flavour.
% Copyright (C) 2017 Dynare Team % Copyright (C) 2017-2019 Dynare Team
% %
% This code 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 % it under the terms of the GNU General Public License as published by
...@@ -17,5 +20,10 @@ function b = is64bit() ...@@ -17,5 +20,10 @@ function b = is64bit()
% 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/>.
[~, maxsize] = computer(); if ispc
b = (maxsize > 2^31); arch = getenv('PROCESSOR_ARCHITECTURE');
\ No newline at end of file else
[~, arch] = system('uname -m');
end
b = ~isempty(strfind(arch, '64'));
function x13_binary = select_x13_binary() function x13_binary = select_x13_binary(warn_only)
% Copyright (C) 2017 Dynare Team % Returns the path to the X13 binary. If no X13 binary can be found, raises an
% error (unless warn_only=true, in which case it returns an empty string and
% displays a warning).
% Copyright (C) 2017-2019 Dynare Team
% %
% This code 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 % it under the terms of the GNU General Public License as published by
...@@ -15,6 +19,10 @@ function x13_binary = select_x13_binary() ...@@ -15,6 +19,10 @@ function x13_binary = select_x13_binary()
% 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 nargin < 1
warn_only = false;
end
dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m',''); dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m','');
dseries_x13_root = sprintf('%s%s%s%s%s%s%s', dseries_src_root, '..', filesep(), 'externals', filesep(), 'x13', filesep()); dseries_x13_root = sprintf('%s%s%s%s%s%s%s', dseries_src_root, '..', filesep(), 'externals', filesep(), 'x13', filesep());
...@@ -26,15 +34,16 @@ if ismac() ...@@ -26,15 +34,16 @@ if ismac()
x13_binary = sprintf('%s%s%s%s', x13_binary, '32', filesep(), 'x13as'); x13_binary = sprintf('%s%s%s%s', x13_binary, '32', filesep(), 'x13as');
end end
elseif isunix() elseif isunix()
[status, x13_binary] = system('which x13as'); x13_binary = sprintf('%s%s%s', dseries_x13_root, 'linux', filesep());
if ~status if is64bit()
x13_binary = deblank(x13_binary); x13_binary = sprintf('%s%s%s%s', x13_binary, '64', filesep(), 'x13as');
else else
x13_binary = sprintf('%s%s%s', dseries_x13_root, 'linux', filesep()); x13_binary = sprintf('%s%s%s%s', x13_binary, '32', filesep(), 'x13as');
if is64bit() end
x13_binary = sprintf('%s%s%s%s', x13_binary, '64', filesep(), 'x13as'); if ~exist(x13_binary, 'file')
else [status, x13_binary] = system('which x13as');
x13_binary = sprintf('%s%s%s%s', x13_binary, '32', filesep(), 'x13as'); if ~status
x13_binary = deblank(x13_binary);
end end
end end
elseif ispc() elseif ispc()
...@@ -45,5 +54,14 @@ elseif ispc() ...@@ -45,5 +54,14 @@ elseif ispc()
x13_binary = sprintf('%s%s%s%s', x13_binary, '32', filesep(), 'x13as.exe'); x13_binary = sprintf('%s%s%s%s', x13_binary, '32', filesep(), 'x13as.exe');
end end
else else
error('X13 binary is not available for this plateform') error('Unsupported platform')
end end
\ No newline at end of file
if ~exist(x13_binary, 'file')
if warn_only
warning('X13 binary is not available.\nIf you are under Debian or Ubuntu, you can install it through your package manager, with ''apt install x13as''.\nIf you are under Windows or macOS, this probably means that you did not install the dseries toolbox through an official package.\n');
x13_binary = '';
else
error('Can''t find X13 binary');
end
end