diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000000000000000000000000000000000..50391c3197c05c062a44f7f8a6dc7fbb421232ae --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "contrib/jsonlab"] + path = contrib/jsonlab + url = https://github.com/fangq/jsonlab.git diff --git a/contrib/jsonlab b/contrib/jsonlab new file mode 160000 index 0000000000000000000000000000000000000000..7499bd8fae221d3018d31b359a74422237a8b8ec --- /dev/null +++ b/contrib/jsonlab @@ -0,0 +1 @@ +Subproject commit 7499bd8fae221d3018d31b359a74422237a8b8ec diff --git a/src/initialize_mdbnomics.m b/src/initialize_mdbnomics.m index a0ff859e41e95ebd26e67d9807cbe06e4b6f393b..3cf356e25da0d3a3437804d78b47689aa2769835 100644 --- a/src/initialize_mdbnomics.m +++ b/src/initialize_mdbnomics.m @@ -17,11 +17,12 @@ function initialize_mdbnomics() % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -% Get the path to the dseries toolbox. +% Get the path to the mdbnomics toolbox. mdbnomics_src_root = strrep(which('initialize_mdbnomics'), 'initialize_mdbnomics.m', ''); % Set the subfolders to be added in the path. -p = {'utils'}; +p = {'utils' ; ... + '/../contrib/jsonlab'}; % Add missing routines if dynare is not in the path if ~exist('OCTAVE_VERSION', 'builtin') || ~exist('contains','builtin') @@ -36,6 +37,10 @@ if ~exist('matlab_ver_less_than','file') p{end+1} = 'missing/matlab_ver_less_than'; end +if ~exist('octave_ver_less_than','file') + p{end+1} = 'missing/matlab_ver_less_than'; +end + if exist('OCTAVE_VERSION', 'builtin') && ~exist('user_has_octave_forge_package','file') p{end+1} = 'missing/user_has_octave_forge_package'; end @@ -44,4 +49,11 @@ end P = cellfun(@(c)[mdbnomics_src_root c], p, 'uni', false); addpath(P{:}); +% Check minimal MATLAB and Octave requirements. +if isoctave && octave_ver_less_than('6') + error('The minimum Octave requirement of this package is version 6.'); +elseif matlab_ver_less_than('8.5') + error('The minimum MATLAB requirement of this package is R2015a.'); +end + assignin('caller', 'mdbnomics_src_root', mdbnomics_src_root); diff --git a/src/missing/octave_ver_less_than/octave_ver_less_than.m b/src/missing/octave_ver_less_than/octave_ver_less_than.m new file mode 100644 index 0000000000000000000000000000000000000000..0f4fc1fa29900a1fed3671c6d74c2e77d01876ce --- /dev/null +++ b/src/missing/octave_ver_less_than/octave_ver_less_than.m @@ -0,0 +1,37 @@ +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 diff --git a/src/utils/iter_filtered_series.m b/src/utils/iter_filtered_series.m index 2a2c818a957b7231cbf8f6d1adfeeef72fc31613..a83774804c483afa47f806f315183239841e214c 100644 --- a/src/utils/iter_filtered_series.m +++ b/src/utils/iter_filtered_series.m @@ -51,7 +51,10 @@ for gg = 1:size(grouped_series, 2) posted_series_list{series} = posted_series; end - json_request = sprintf('{"filters":%s,"series":%s}', dbnomics_filters, jsonencode(posted_series_list)); + posted_series_list = savejson('',posted_series_list, 'Compact', 1); + posted_series_list = regexprep(posted_series_list,{' [[',']]'},{'[',']'}); + json_request = sprintf('{"filters":%s,"series":%s}', dbnomics_filters, posted_series_list); + try response = webwrite(apply_endpoint_url, json_request, opts); catch