replace reporting code with submodule. closes #811

time-shift
Houtan Bastani 2015-02-24 16:38:36 +01:00
parent 2809afaa11
commit e19f03b420
79 changed files with 5 additions and 4283 deletions

3
.gitmodules vendored
View File

@ -21,3 +21,6 @@
path = matlab/modules/dseries
url = https://github.com/DynareTeam/dseries.git
branch = old-oop-style
[submodule "matlab/modules/reporting"]
path = matlab/modules/reporting
url = https://github.com/DynareTeam/reporting.git

View File

@ -66,7 +66,7 @@ addpath([dynareroot '/utilities/doc/'])
addpath([dynareroot '/utilities/tests/src/'])
addpath([dynareroot '/utilities/dataset/'])
addpath([dynareroot '/utilities/general/'])
addpath([dynareroot '/reports/'])
addpath([dynareroot '/modules/reporting/src/'])
% For functions that exist only under some Octave versions
% or some MATLAB versions, and for which we provide some replacement functions

@ -0,0 +1 @@
Subproject commit d242c92493693a8dc3b369f36b8762d8c31179fd

View File

@ -1,22 +0,0 @@
function o = addSeries(o, varargin)
% function o = addSeries(o, varargin)
% Copyright (C) 2013-2014 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/>.
o.series{end+1} = report_series(varargin{:});
end

View File

@ -1,32 +0,0 @@
function display(o)
%function display(o)
% Display a Graph object
%
% INPUTS
% o [graph] graph object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
display_reporting_object(o);
end

View File

@ -1,35 +0,0 @@
function lastIndex = end(o, k, n)
% function lastIndex = end(o, k, n)
% End keyword
%
% INPUTS
% o [graph] graph object
% k [integer] index where end appears
% n [integer] number of indices
%
% OUTPUTS
% lastIndex [integer] last graph index
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
assert(k==1 && n==1, '@graph/end: graph only has one dimension');
lastIndex = length(o.series);
end

View File

@ -1,219 +0,0 @@
function o = graph(varargin)
%function o = graph(varargin)
% Graph Class Constructor
%
% INPUTS
% varargin 0 args : empty graph object
% 1 arg : must be graph object (return a copy of arg)
% > 1 args: option/value pairs (see structure below for
% options)
%
% OUTPUTS
% o [graph] graph object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
o = struct;
o.series = {};
o.title = '';
o.titleFormat = '';
o.titleFontSize = 'normalsize';
o.ylabel = '';
o.xlabel = '';
o.axisShape = 'box';
o.graphDirName = 'tmpRepDir';
o.graphName = '';
o.data = '';
o.seriesToUse = '';
o.xrange = '';
o.xAxisTight = true;
o.yrange = '';
o.yAxisTight = false;
o.shade = '';
o.shadeColor = 'green';
o.shadeOpacity = 20;
o.showGrid = true;
o.showLegend = false;
o.legendAt = [];
o.showLegendBox = false;
o.legendLocation = 'south east';
o.legendOrientation = 'horizontal';
o.legendFontSize = 'tiny';
o.showZeroline = false;
o.zeroLineColor = 'black';
o.xTicks = [];
o.xTickLabels = {};
o.xTickLabelRotation = 0;
o.xTickLabelAnchor = 'east';
o.yTickLabelScaled = true;
o.yTickLabelPrecision = 0;
o.yTickLabelFixed = true;
o.yTickLabelZeroFill = true;
o.tickFontSize = 'normalsize';
o.width = 6;
o.height = 4.5;
o.miscTikzPictureOptions = '';
o.miscTikzAxisOptions = '';
o.writeCSV = false;
if nargin == 1
assert(isa(varargin{1}, 'graph'),['@graph.graph: with one arg you ' ...
'must pass a graph object']);
o = varargin{1};
return;
elseif nargin > 1
if round(nargin/2) ~= nargin/2
error(['@graph.graph: options must be supplied in name/value ' ...
'pairs.']);
end
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
ind = find(strcmpi(optNames, pair{1}));
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@graph.graph: %s is not a recognized option.', pair{1});
end
end
end
% Check options provided by user
if ischar(o.title)
o.title = {o.title};
end
assert(iscellstr(o.title), '@graph.graph: title must be a cell array of string(s)');
assert(ischar(o.titleFormat), '@graph.graph: titleFormat file must be a string');
assert(ischar(o.xlabel), '@graph.graph: xlabel file must be a string');
assert(ischar(o.ylabel), '@graph.graph: ylabel file must be a string');
assert(ischar(o.miscTikzPictureOptions), '@graph.graph: miscTikzPictureOptions file must be a string');
assert(ischar(o.miscTikzAxisOptions), '@graph.graph: miscTikzAxisOptions file must be a string');
assert(ischar(o.graphName), '@graph.graph: graphName must be a string');
assert(ischar(o.graphDirName), '@graph.graph: graphDirName must be a string');
assert(islogical(o.showGrid), '@graph.graph: showGrid must be either true or false');
assert(islogical(o.xAxisTight), '@graph.graph: xAxisTight must be either true or false');
assert(islogical(o.yAxisTight), '@graph.graph: yAxisTight must be either true or false');
assert(islogical(o.showLegend), '@graph.graph: showLegend must be either true or false');
assert(isempty(o.legendAt) || (isfloat(o.legendAt) && length(o.legendAt)==2), ...
'@graph.graph: legendAt must be a double array of size two');
assert(islogical(o.showLegendBox), '@graph.graph: showLegendBox must be either true or false');
assert(islogical(o.showZeroline), '@graph.graph: showZeroline must be either true or false');
assert(isfloat(o.shadeOpacity) && length(o.shadeOpacity)==1 && ...
o.shadeOpacity >= 0 && o.shadeOpacity <= 100, ...
'@graph.graph: o.shadeOpacity must be a real in [0 100]');
assert(isfloat(o.width), '@graph.graph: o.width must be a real number');
assert(isfloat(o.height), '@graph.graph: o.height must be a real number');
assert(isfloat(o.xTickLabelRotation), '@graph.graph: o.xTickLabelRotation must be a real number');
assert(ischar(o.xTickLabelAnchor), '@graph.graph: xTickLabelAnchor must be a string');
assert(isint(o.yTickLabelPrecision), '@graph.graph: o.yTickLabelPrecision must be an integer');
assert(islogical(o.yTickLabelFixed), '@graph.graph: yTickLabelFixed must be either true or false');
assert(islogical(o.yTickLabelZeroFill), '@graph.graph: yTickLabelZeroFill must be either true or false');
assert(islogical(o.yTickLabelScaled), '@graph.graph: yTickLabelScaled must be either true or false');
assert(islogical(o.writeCSV), '@graph.graph: writeCSV must be either true or false');
assert(ischar(o.shadeColor), '@graph.graph: shadeColor must be a string');
assert(ischar(o.zeroLineColor), '@graph.graph: zeroLineColor must be a string');
assert(any(strcmp(o.axisShape, {'box', 'L'})), ['@graph.graph: axisShape ' ...
'must be one of ''box'' or ''L''']);
valid_legend_locations = ...
{'south west','south east','north west','north east','outer north east'};
assert(any(strcmp(o.legendLocation, valid_legend_locations)), ...
['@graph.graph: legendLocation must be one of ' strjoin(valid_legend_locations, ' ')]);
valid_font_sizes = {'tiny', 'scriptsize', 'footnotesize', 'small', ...
'normalsize', 'large', 'Large', 'LARGE', 'huge', 'Huge'};
assert(any(strcmp(o.legendFontSize, valid_font_sizes)), ...
['@graph.graph: legendFontSize must be one of ' strjoin(valid_font_sizes)]);
assert(any(strcmp(o.titleFontSize, valid_font_sizes)), ...
['@graph.graph: titleFontSize must be one of ' strjoin(valid_font_sizes)]);
assert(any(strcmp(o.tickFontSize, valid_font_sizes)), ...
['@graph.graph: tickFontSize must be one of ' strjoin(valid_font_sizes)]);
valid_legend_orientations = {'vertical', 'horizontal'};
assert(any(strcmp(o.legendOrientation, valid_legend_orientations)), ...
['@graph.graph: legendOrientation must be one of ' strjoin(valid_legend_orientations, ' ')]);
assert(isempty(o.shade) || (isdates(o.shade) && o.shade.ndat >= 2), ...
['@graph.graph: shade is specified as a dates range, e.g. ' ...
'''dates(''1999q1''):dates(''1999q3'')''.']);
assert(isempty(o.xrange) || (isdates(o.xrange) && o.xrange.ndat >= 2), ...
['@graph.graph: xrange is specified as a dates range, e.g. ' ...
'''dates(''1999q1''):dates(''1999q3'')''.']);
assert(isempty(o.yrange) || (isfloat(o.yrange) && length(o.yrange) == 2 && ...
o.yrange(1) < o.yrange(2)), ...
['@graph.graph: yrange is specified an array with two float entries, ' ...
'the lower bound and upper bound.']);
assert(isempty(o.data) || isdseries(o.data), ['@graph.graph: data must ' ...
'be a dseries']);
assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ['@graph.graph: ' ...
'seriesToUse must be a cell array of string(s)']);
assert(isempty(o.xTicks) || isfloat(o.xTicks),...
'@graph.graph: xTicks must be a numerical array');
assert(iscellstr(o.xTickLabels) || (ischar(o.xTickLabels) && strcmpi(o.xTickLabels, 'ALL')), ...
['@graph.graph: xTickLabels must be a cell array of strings or ' ...
'equivalent to the string ''ALL''']);
if ~isempty(o.xTickLabels)
assert((ischar(o.xTickLabels) && strcmpi(o.xTickLabels, 'ALL')) || ...
~isempty(o.xTicks), ['@graph.graph: if you set xTickLabels and ' ...
'it''s not equal to ''ALL'', you must set xTicks']);
end
if ~isempty(o.xTicks)
assert(~isempty(o.xTickLabels), '@graph.graph: if you set xTicks, you must set xTickLabels');
end
% using o.seriesToUse, create series objects and put them in o.series
if ~isempty(o.data)
if isempty(o.seriesToUse)
for i=1:o.data.vobs
o.series{end+1} = report_series('data', o.data{o.data.name{i}});
end
else
for i=1:length(o.seriesToUse)
o.series{end+1} = report_series('data', o.data{o.seriesToUse{i}});
end
end
end
o = rmfield(o, 'seriesToUse');
o = rmfield(o, 'data');
if ~exist(o.graphDirName, 'file')
mkdir(o.graphDirName);
end
% Create graph object
o = class(o, 'graph');
end

View File

@ -1,49 +0,0 @@
function B = subsasgn(A, S, V)
% function B = subsasgn(A, S, V)
% Copyright (C) 2013-2014 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/>.
B = A;
if length(S) > 1
for i=1:(length(S)-1)
B = subsref(B, S(i));
end
B = subsasgn(B, S(end), V);
B = subsasgn(A, S(1:(end-1)), B);
return
end
switch S.type
case '()'
index = S.subs{:};
assert(isnumeric(index));
B.series{index} = V;
case '.'
switch S.subs
case fieldnames(A)
B.(S.subs) = V;
otherwise
error(['@graph.subsasgn: field ' S.subs 'does not exist']);
end
case '{}'
assert(isint(S.subs{1}));
B{S.subs{1}} = V;
otherwise
error('@graph.subsasgn: syntax error');
end
end

View File

@ -1,53 +0,0 @@
function A = subsref(A, S)
%function A = subsref(A, S)
% Copyright (C) 2013-2014 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/>.
switch S(1).type
case '.'
switch S(1).subs
case fieldnames(A)
A = A.(S(1).subs);
case methods(A)
if areParensNext(S)
A = feval(S(1).subs, A, S(2).subs{:});
S = shiftS(S,1);
else
A = feval(S(1).subs, A);
end
otherwise
error(['@graph.subsref: unknown field or method: ' S(1).subs]);
end
case '()'
if isempty(S(1).subs{:})
A = A.series;
else
assert(isnumeric(S(1).subs{:}));
A = A.series{S(1).subs{:}};
end
case '{}'
A = A.series{S(1).subs{:}};
otherwise
error('@graph.subsref: impossible case')
end
S = shiftS(S,1);
if length(S) >= 1
A = subsref(A, S);
end
end

View File

@ -1,39 +0,0 @@
function o = write(o, fid, pg, sec, row, col)
%function o = write(o, fid, pg, sec, row, col)
% Write a Graph object
%
% INPUTS
% o [graph] graph object
% fid [integer] file id
% pg [integer] this page number
% sec [integer] this section number
% row [integer] this row number
% col [integer] this col number
%
% OUTPUTS
% o [graph] graph object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
assert(fid ~= -1);
o = writeGraphFile(o, pg, sec, row, col);
fprintf(fid, '\\input{%s}', o.graphName);
end

View File

@ -1,271 +0,0 @@
function o = writeGraphFile(o, pg, sec, row, col)
%function o = writeGraphFile(o, pg, sec, row, col)
% Write the tikz file that contains the graph
%
% INPUTS
% o [graph] graph object
% pg [integer] this page number
% sec [integer] this section number
% row [integer] this row number
% col [integer] this col number
%
% OUTPUTS
% o [graph] graph object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
ne = length(o.series);
if ne < 1
warning('@graph.writeGraphFile: no series to plot, returning');
return;
end
if isempty(o.graphName)
o.graphName = sprintf('%s/graph_pg%d_sec%d_row%d_col%d.tex', o.graphDirName, pg, sec, row, col);
else
o.graphName = [o.graphDirName '/' o.graphName];
end
[fid, msg] = fopen(o.graphName, 'w');
if fid == -1
error(['@graph.writeGraphFile: ' msg]);
end
fprintf(fid, '\\begin{tikzpicture}[baseline');
if ~isempty(o.miscTikzPictureOptions)
fprintf(fid, ',%s', o.miscTikzPictureOptions);
end
fprintf(fid, ']');
if isempty(o.xrange)
dd = getMaxRange(o.series);
else
dd = o.xrange;
end
fprintf(fid, '\\begin{axis}[%%\n');
% set tick labels
if isempty(o.xTickLabels)
stringsdd = strings(dd);
if ~isempty(o.shade)
x1 = find(strcmpi(date2string(o.shade(1)), stringsdd));
x2 = find(strcmpi(date2string(o.shade(end)), stringsdd));
if x1 == 1
x = [1 x2 dd.ndat];
xTickLabels = [stringsdd(1) stringsdd(x2) stringsdd(end)];
elseif x2 == dd.ndat
x = [1 x1 dd.ndat];
xTickLabels = [stringsdd(1) stringsdd(x1) stringsdd(end)];
else
x = [1 x1 x2 dd.ndat];
xTickLabels = [stringsdd(1) stringsdd(x1) stringsdd(x2) stringsdd(end)];
end
else
x = [1 dd.ndat];
xTickLabels = [stringsdd(1) stringsdd(end)];
end
fprintf(fid, 'xminorticks=true,\nyminorticks=true,\n');
elseif iscell(o.xTickLabels)
fprintf(fid,'minor xtick,\n');
x = o.xTicks;
xTickLabels = o.xTickLabels;
else
x = [1:dd.ndat];
xTickLabels = strings(dd);
end
fprintf(fid, 'xticklabels={');
xlen = length(x);
for i = 1:xlen
fprintf(fid,'%s,',lower(xTickLabels{i}));
end
fprintf(fid, '},\nxtick={');
for i = 1:xlen
fprintf(fid, '%d',x(i));
if i ~= length(x)
fprintf(fid,',');
end
end
fprintf(fid, '},\ny tick label style={\n/pgf/number format/.cd,\n');
if o.yTickLabelFixed
fprintf(fid, 'fixed,\n');
end
if o.yTickLabelZeroFill
fprintf(fid, 'zerofill,\n');
end
fprintf(fid, 'precision=%d,\n/tikz/.cd\n},\n', o.yTickLabelPrecision);
fprintf(fid, 'x tick label style={rotate=%f', o.xTickLabelRotation);
if o.xTickLabelRotation ~= 0
fprintf(fid, ',anchor=%s', o.xTickLabelAnchor);
end
fprintf(fid, ['},\n',...
'width=%fin,\n'...
'height=%fin,\n'...
'scale only axis,\n'...
'unbounded coords=jump,\n'], o.width, o.height);
if strcmpi(o.axisShape, 'box')
fprintf(fid, 'axis lines=box,\n');
elseif strcmpi(o.axisShape, 'L')
fprintf(fid, 'axis x line=bottom,\naxis y line=left,\n');
end
if ~isempty(o.title{1})
fprintf(fid, 'title style={align=center');
if ~isempty(o.titleFormat)
fprintf(fid, ',font=%s', o.titleFormat);
end
fprintf(fid, '},\ntitle=');
nt = length(o.title);
for i=1:nt
fprintf(fid, '%s', o.title{i});
if i ~= nt
fprintf(fid, '\\\\');
end
end
fprintf(fid, ',\n');
end
if o.xAxisTight
fprintf(fid, 'enlarge x limits=false,\n');
else
fprintf(fid, 'enlarge x limits=true,\n');
end
if isempty(o.yrange)
if o.yAxisTight
fprintf(fid, 'enlarge y limits=false,\n');
else
fprintf(fid, 'enlarge y limits=true,\n');
end
else
fprintf(fid, 'ymin=%f,\nymax=%f,\n',o.yrange(1),o.yrange(2));
end
fprintf(fid, 'xmin = 1,\nxmax = %d,\n', length(dd));
if o.showLegend
fprintf(fid, 'legend style={');
if ~o.showLegendBox
fprintf(fid, 'draw=none,');
end
fprintf(fid, 'font=\\%s,', o.legendFontSize);
if strcmp(o.legendOrientation, 'horizontal')
fprintf(fid,'legend columns=-1,');
end
if isempty(o.legendAt)
fprintf(fid, '},\nlegend pos=%s,\n', o.legendLocation);
else
fprintf(fid, 'at={(%f,%f)}},\n',o.legendAt(1),o.legendAt(2));
end
end
fprintf(fid, 'tick label style={font=\\%s},\n', o.tickFontSize);
if o.showGrid
fprintf(fid, 'xmajorgrids=true,\nymajorgrids=true,\n');
end
if ~isempty(o.xlabel)
fprintf(fid, 'xlabel=%s,\n', o.xlabel);
end
if ~isempty(o.ylabel)
fprintf(fid, 'ylabel=%s,\n', o.ylabel);
end
if ~o.yTickLabelScaled
fprintf(fid, 'scaled y ticks = false,\n');
end
if ~isempty(o.miscTikzAxisOptions)
fprintf(fid, '%s', o.miscTikzAxisOptions);
end
fprintf(fid, ']\n');
if ~isempty(o.title{1})
fprintf(fid, '\\pgfplotsset{every axis title/.append style={}}=[font=\\%s]\n', o.titleFontSize);
end
if ~isempty(o.shade)
fprintf(fid, '%%shading\n');
stringsdd = strings(dd);
x1 = find(strcmpi(date2string(o.shade(1)), stringsdd));
x2 = find(strcmpi(date2string(o.shade(end)), stringsdd));
assert(~isempty(x1) && ~isempty(x2), ['@graph.writeGraphFile: either ' ...
date2string(o.shade(1)) ' or ' date2string(o.shade(end)) ' is not in the date ' ...
'range of data selected.']);
if x1 == 1
fprintf(fid,['\\begin{pgfonlayer}{background0}\n\\fill[%s!%f]\n(axis ' ...
'cs:\\pgfkeysvalueof{/pgfplots/xmin},\\pgfkeysvalueof{/pgfplots/ymin})\nrectangle (axis ' ...
'cs:%f,\\pgfkeysvalueof{/pgfplots/ymax});\n\\end{pgfonlayer}\n'], ...
o.shadeColor, o.shadeOpacity, x2);
elseif x2 == dd.ndat
fprintf(fid,['\\begin{pgfonlayer}{background0}\n\\fill[%s!%f]\n(axis ' ...
'cs:%f,\\pgfkeysvalueof{/pgfplots/ymin})\nrectangle (axis ' ...
'cs:\\pgfkeysvalueof{/pgfplots/xmax},\\pgfkeysvalueof{/' ...
'pgfplots/ymax});\n\\end{pgfonlayer}\n'], ...
o.shadeColor, o.shadeOpacity, x1);
else
fprintf(fid,['\\begin{pgfonlayer}{background0}\n\\fill[%s!%f]\n(axis ' ...
'cs:%f,\\pgfkeysvalueof{/pgfplots/ymin})\nrectangle (axis ' ...
'cs:%f,\\pgfkeysvalueof{/pgfplots/ymax});\n\\end{pgfonlayer}\n'], ...
o.shadeColor, o.shadeOpacity, x1, x2);
end
end
if o.showZeroline
fprintf(fid, '%%zeroline\n\\addplot[%s,line width=.5,forget plot] coordinates {(1,0)(%d,0)};\n', ...
o.zeroLineColor, dd.ndat);
end
if o.writeCSV
csvseries = dseries();
end
for i=1:ne
o.series{i}.writeSeriesForGraph(fid, dd);
if o.writeCSV
csvseries = [csvseries ...
o.series{i}.data(dd).set_names([...
o.series{i}.data.name{:} '_' ...
o.series{i}.graphLegendName '_' ...
o.series{i}.graphLineColor '_' ...
o.series{i}.graphLineStyle '_' ...
num2str(o.series{i}.graphLineWidth) '_' ...
o.series{i}.graphMarker '_' ...
o.series{i}.graphMarkerEdgeColor '_' ...
o.series{i}.graphMarkerFaceColor '_' ...
num2str(o.series{i}.graphMarkerSize)]) ...
];
end
if o.showLegend
le = o.series{i}.getNameForLegend();
if ~isempty(le)
fprintf(fid, '\\addlegendentry{%s}\n', le);
end
end
end
if o.writeCSV
csvseries.save(strrep(o.graphName, '.tex', ''), 'csv');
end
fprintf(fid, '\\end{axis}\n\\end{tikzpicture}%%');
if fclose(fid) == -1
error('@graph.writeGraphFile: closing %s\n', o.filename);
end
end

View File

@ -1,34 +0,0 @@
function p = addSection(p, varargin)
%function p = addSection(p, varargin)
% Add a section to the Cell Array of sections in the report
%
% INPUTS
% 1 args => add empty section
% 2 args => add given section
% 3 args => add section at index
%
% OUTPUTS
% updated page object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
p.sections{end+1} = section(varargin{:});
end

View File

@ -1,32 +0,0 @@
function display(o)
%function display(o)
% Display a Page object
%
% INPUTS
% o [page] page object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
display_reporting_object(o);
end

View File

@ -1,35 +0,0 @@
function lastIndex = end(o, k, n)
% function lastIndex = end(o, k, n)
% End keyword
%
% INPUTS
% o [page] page object
% k [integer] index where end appears
% n [integer] number of indices
%
% OUTPUTS
% lastIndex [integer] last sections index
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013 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/>.
assert(k==1 && n==1, '@page/end: page only has one dimension');
lastIndex = numSections(o);
end

View File

@ -1,32 +0,0 @@
function ns = numSections(p)
%function ns = numSections(p)
% return the number of sections currently in the page
%
% INPUTS
% none
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
ns = length(p.sections);
end

View File

@ -1,101 +0,0 @@
function o = page(varargin)
%function o = page(varargin)
% Page Class Constructor
%
% INPUTS
% 0 args => empty page
% 1 arg (page class) => copy object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2015 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/>.
o = struct;
o.paper = '';
o.title = {''};
titleFormatDefalut = {'\large\bfseries'};
o.titleFormat = titleFormatDefalut;
o.titleTruncate = '';
o.orientation = '';
o.footnote = {};
o.sections = {};
if nargin == 1
assert(isa(varargin{1}, 'page'), ['@page.page: with one arg to Page ' ...
'constructor, you must pass a page object']);
o = varargin{1};
return;
elseif nargin > 1
if round(nargin/2) ~= nargin/2
error(['@page.page: options must be supplied in name/value ' ...
'pairs.']);
end
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
ind = find(strcmpi(optNames, pair{1}));
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@page.page: %s is not a recognized option.', pair{1});
end
end
end
% Check options provided by user
if ischar(o.title)
o.title = {o.title};
end
if ischar(o.titleFormat)
o.titleFormat = {o.titleFormat};
end
if length(o.title) ~= length(o.titleFormat)
o.titleFormat = repmat(titleFormatDefalut, 1, length(o.title));
end
assert(iscellstr(o.title), ...
'@page.page: title must be a cell array of strings');
assert(iscellstr(o.titleFormat), ...
'@page.page: titleFormat must be a cell array of strings');
assert((ischar(o.titleTruncate) && isempty(o.titleTruncate)) || ...
isint(o.titleTruncate), ...
'@page.page: titleTruncate must be empty or an integer.');
valid_paper = {'a4', 'letter'};
assert(any(strcmp(o.paper, valid_paper)), ...
['@page.page: paper must be one of ' strjoin(valid_paper, ' ')]);
valid_orientation = {'portrait', 'landscape'};
assert(any(strcmp(o.orientation, valid_orientation)), ...
['@page.page: orientation must be one of ' strjoin(valid_orientation, ' ')]);
if ischar(o.footnote)
o.footnote = {o.footnote};
end
assert(iscellstr(o.footnote), ...
'@page.page: footnote must be a cell array of string(s)');
% Create page object
o = class(o, 'page');
end

View File

@ -1,46 +0,0 @@
function B = subsasgn(A, S, V)
% function B = subsasgn(A, S, V)
% Copyright (C) 2013 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/>.
B = A;
if length(S) > 1
for i=1:(length(S)-1)
B = subsref(B, S(i));
end
B = subsasgn(B, S(end), V);
B = subsasgn(A, S(1:(end-1)), B);
return
end
switch S.type
case '()'
index = S.subs{:};
assert(isnumeric(index));
B{index} = V;
case '.'
switch S.subs
case fieldnames(A)
B.(S.subs) = V;
otherwise
error(['@page.subsasgn: field ' S.subs 'does not exist']);
end
otherwise
error('@page.subsasgn: syntax error');
end
end

View File

@ -1,48 +0,0 @@
function A = subsref(A, S)
%function A = subsref(A, S)
% Copyright (C) 2013-2014 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/>.
switch S(1).type
case '.'
switch S(1).subs
case fieldnames(A)
A = A.(S(1).subs);
case methods(A)
if areParensNext(S)
A = feval(S(1).subs, A, S(2).subs{:});
S = shiftS(S,1);
else
A = feval(S(1).subs, A);
end
otherwise
error(['@page.subsref: unknown field or method: ' S(1).subs]);
end
case '()'
A = getSections(A, S(1).subs{:});
case '{}'
error(['@page.subsref: ' S(1).type ' indexing not supported.']);
otherwise
error('@page.subsref: impossible case')
end
S = shiftS(S,1);
if length(S) >= 1
A = subsref(A, S);
end
end

View File

@ -1,66 +0,0 @@
function o = write(o, fid, pg)
%function o = write(o, fid, pg)
% Write a Page object
%
% INPUTS
% o [page] page object
% fid [integer] file id
% pg [integer] this page number
%
% OUTPUTS
% o [page] page object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2015 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/>.
assert(fid ~= -1);
fprintf(fid, '\n%% Page Object\n');
if strcmpi(o.orientation, 'landscape')
fprintf(fid, '\\begin{landscape}\n');
end
for i=1:length(o.footnote)
fprintf(fid, '\\blfootnote{\\tiny %d. %s}', i, o.footnote{i});
end
fprintf(fid,'\n');
fprintf(fid, '\\begin{tabular}[t]{c}\n');
for i=1:length(o.title)
if isint(o.titleTruncate)
if length(o.title{i}) > o.titleTruncate
o.title{i} = o.title{i}(1:o.titleTruncate);
end
end
fprintf(fid,'\\multicolumn{1}{c}{%s %s}\\\\\n', o.titleFormat{i}, o.title{i});
end
nps = length(o.sections);
for i=1:nps
o.sections{i}.write(fid, pg, i);
end
fprintf(fid, '\\end{tabular}\n');
if strcmpi(o.orientation, 'landscape')
fprintf(fid, '\\end{landscape}\n');
end
fprintf(fid, '\\clearpage\n');
fprintf(fid, '%% End Page Object\n\n');
end

View File

@ -1,32 +0,0 @@
function display(o)
%function display(o)
% Display a Paragraph object
%
% INPUTS
% o [paragraph] paragraph object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2014 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/>.
display_reporting_object(o);
end

View File

@ -1,63 +0,0 @@
function o = paragraph(varargin)
%function o = paragraph(varargin)
% Instantiates a paragraph object
% Copyright (C) 2014 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/>.
o = struct;
o.balancedCols = false;
o.cols = 1;
o.heading = '';
o.indent = true;
o.text = '';
if nargin == 1
assert(isa(varargin{1}, 'paragraph'),['With one arg to Paragraph constructor, ' ...
'you must pass a paragraph object']);
o = varargin{1};
return;
elseif nargin > 1
if round(nargin/2) ~= nargin/2
error(['@paragraph.paragraph: options must be supplied in name/value ' ...
'pairs.']);
end
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
ind = find(strcmpi(optNames, pair{1}));
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@paragraph.paragraph: %s is not a recognized option.', pair{1});
end
end
end
assert(islogical(o.indent), '@paragraph.paragraph: indent must be either true or false');
assert(islogical(o.balancedCols), '@paragraph.paragraph: balancedCols must be either true or false');
assert(isint(o.cols), '@paragraph.paragraph: cols must be an integer');
assert(ischar(o.text), '@paragraph.paragraph: text must be a string');
assert(ischar(o.heading), '@paragraph.paragraph: heading must be a string');
% Create paragraph object
o = class(o, 'paragraph');
end

View File

@ -1,50 +0,0 @@
function B = subsasgn(A, S, V)
% function B = subsasgn(A, S, V)
% Copyright (C) 2014 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/>.
B = A;
if length(S) > 1
for i=1:(length(S)-1)
B = subsref(B, S(i));
end
B = subsasgn(B, S(end), V);
B = subsasgn(A, S(1:(end-1)), B);
return
end
switch S.type
case '()'
index = S.subs{:};
assert(isnumeric(index));
B.elements{index} = V;
case '{}'
index = S.subs{:};
assert(isnumeric(index));
B{index} = V;
case '.'
switch S.subs
case fieldnames(A)
B.(S.subs) = V;
otherwise
error(['@paragraph.subsasgn: field ' S.subs 'does not exist']);
end
otherwise
error('@paragraph.subsasgn: syntax error');
end
end

View File

@ -1,48 +0,0 @@
function A = subsref(A, S)
%function A = subsref(A, S)
% Copyright (C) 2014 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/>.
switch S(1).type
case '.'
switch S(1).subs
case fieldnames(A)
A = A.(S(1).subs);
case methods(A)
if areParensNext(S)
A = feval(S(1).subs, A, S(2).subs{:});
S = shiftS(S,1);
else
A = feval(S(1).subs, A);
end
otherwise
error(['@paragraph.subsref: unknown field or method: ' S(1).subs]);
end
case '()'
A = A.elements{S(1).subs{:}};
case '{}'
error(['@paragraph.subsref: ' S(1).type ' indexing not supported.']);
otherwise
error('@paragraph.subsref: impossible case')
end
S = shiftS(S,1);
if length(S) >= 1
A = subsref(A, S);
end
end

View File

@ -1,70 +0,0 @@
function o = write(o, fid)
%function o = write(o, fid)
% Write Paragraph object
%
% INPUTS
% o [paragraph] paragraph object
% fid [integer] file id
%
% OUTPUTS
% o [paragraph] paragraph object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2014 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/>.
assert(fid ~= -1);
fprintf(fid, '%% Paragraph Object\n\\multicolumn{1}{p{\\textwidth}}{%%\n');
if o.cols ~= 1
bc = '';
if o.balancedCols
bc = '*';
end
fprintf(fid, '\\begin{multicols%s}{%d}%%\n', bc, o.cols);
end
if ~isempty(o.heading)
if o.cols ~= 1
fprintf(fid, '[%s\n]\n', o.heading);
else
fprintf(fid, '%s\\newline \\newline\n', o.heading);
end
end
if o.indent
fprintf(fid, '\\hspace{4ex}');
end
fprintf(fid, '%s', o.text);
if o.cols ~= 1
fprintf(fid, '\\end{multicols%s}\n', bc);
end
fprintf(fid, '}\n%% End Paragraph Object\n\n');
end
%\multicolumn{1}{p{\textwidth}}
%{\begin{multicols}{2}
%Hello, here is some text without a meaning. This text should show what
%a printed text will look like at this place.
%\columnbreak
%If you read this text, you will get no information. Really? Is there
%no information? Is there...
%\end{multicols}}\\

View File

@ -1,34 +0,0 @@
function o = addGraph(o, varargin)
%function o = addGraph(o, varargin)
% Add a graph to the current section of the current page in the report
%
% INPUTS
% o [report] report object
% varargin arguments to @section/addGraph.m
%
% OUTPUTS
% o [report] updated report object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
o.pages{end}.sections{end} = ...
o.pages{end}.sections{end}.addGraph(varargin{:});
end

View File

@ -1,37 +0,0 @@
function o = addPage(o, varargin)
%function o = addPage(o, varargin)
% Add a page to the report
%
% INPUTS
% o [report] report object
% varargin arguments to @section/addGraph.m
%
% OUTPUTS
% o [report] updated report object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
np = length(o.pages) + 1;
if o.showOutput
fprintf(1, 'Adding Page: %d\n', np);
end
o.pages{np} = page('orientation', o.orientation, 'paper', o.paper, varargin{:});
end

View File

@ -1,34 +0,0 @@
function o = addParagraph(o, varargin)
%function o = addParagraph(o, varargin)
% Add a paragraph to the current section of the current page in the report
%
% INPUTS
% o [report] report object
% varargin arguments to @section/addGraph.m
%
% OUTPUTS
% o [report] updated report object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
o.pages{end}.sections{end} = ...
o.pages{end}.sections{end}.addParagraph(varargin{:});
end

View File

@ -1,33 +0,0 @@
function o = addSection(o, varargin)
%function o = addSection(o, varargin)
% Add a section to the current page in the report
%
% INPUTS
% o [report] report object
% varargin arguments to @section/addGraph.m
%
% OUTPUTS
% o [report] updated report object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
o.pages{end} = o.pages{end}.addSection(varargin{:});
end

View File

@ -1,38 +0,0 @@
function o = addSeries(o, varargin)
%function o = addSeries(o, varargin)
% Add a graph to the current section of the current page in the report
%
% INPUTS
% o [report] report object
% varargin arguments to @graph/addSeries
%
% OUTPUTS
% o [report] updated report object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
assert(isa(o.pages{end}.sections{end}.elements{end}, 'graph') || ...
isa(o.pages{end}.sections{end}.elements{end}, 'report_table'), ...
'@report.addSeries: you can only add a series to a report_table or graph object');
o.pages{end}.sections{end}.elements{end} = ...
o.pages{end}.sections{end}.elements{end}.addSeries(varargin{:});
end

View File

@ -1,34 +0,0 @@
function o = addTable(o, varargin)
%function o = addTable(o, varargin)
% Add a table to the current section of the current page in the report
%
% INPUTS
% o [report] report object
% varargin arguments to @section/addTable.m
%
% OUTPUTS
% o [report] updated report object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
o.pages{end}.sections{end} = ...
o.pages{end}.sections{end}.addTable(varargin{:});
end

View File

@ -1,34 +0,0 @@
function o = addVspace(o, varargin)
%function o = addVspace(o, varargin)
% Add a vspace to the current section of the current page in the report
%
% INPUTS
% o [report] report object
% varargin arguments to @section/addVspace.m
%
% OUTPUTS
% o [report] updated report object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
o.pages{end}.sections{end} = ...
o.pages{end}.sections{end}.addVspace(varargin{:});
end

View File

@ -1,122 +0,0 @@
function o = compile(o, varargin)
%function o = compile(o)
% Compile Report Object
%
% INPUTS
% o [report] report object
% varargin [char] allows user to change report compiler for a
% given run of compile.
%
% OUTPUTS
% o [report] report object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2015 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/>.
opts.compiler = o.compiler;
opts.showReport = true;
opts.showOutput = o.showOutput;
if nargin > 1
if round((nargin-1)/2) ~= (nargin-1)/2
error('@report.compile: options must be supplied in name/value pairs');
end
optNames = fieldnames(opts);
% overwrite default values
for pair = reshape(varargin, 2, [])
ind = find(strcmpi(optNames, pair{1}));
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
opts.(optNames{ind}) = pair{2};
else
error('@report.compile: %s is not a recognized option.', pair{1});
end
end
end
assert(ischar(opts.compiler), '@report.compile: compiler file must be a string');
assert(islogical(opts.showReport), '@report.compile: showReport must be either true or false');
assert(islogical(opts.showOutput), '@report.compile: showOutput must be either true or false');
if ~exist(o.fileName, 'file')
o.write();
end
middle = ' ./';
options = '-synctex=1 -halt-on-error';
if isoctave
echo = 1;
else
echo = '-echo';
end
if isempty(opts.compiler)
if strncmp(computer, 'MACI', 4) || ~isempty(regexpi(computer, '.*apple.*', 'once'))
% Add most likely places for pdflatex to exist outside of default $PATH
if opts.showOutput
[status, opts.compiler] = ...
system(['PATH=$PATH:/usr/texbin:/usr/local/bin:/usr/local/sbin;' ...
'which pdflatex'], echo);
else
[status, opts.compiler] = ...
system('PATH=$PATH:/usr/texbin:/usr/local/bin:/usr/local/sbin;which pdflatex');
end
elseif strcmp(computer, 'PCWIN') || strcmp(computer, 'PCWIN64')
if opts.showOutput
[status, opts.compiler] = system('findtexmf --file-type=exe pdflatex', echo);
else
[status, opts.compiler] = system('findtexmf --file-type=exe pdflatex');
end
middle = ' ';
opts.compiler = ['"' strtrim(opts.compiler) '"'];
else % gnu/linux
if opts.showOutput
[status, opts.compiler] = system('which pdflatex', echo);
else
[status, opts.compiler] = system('which pdflatex');
end
end
assert(status == 0, ...
'@report.compile: Could not find a tex compiler on your system');
opts.compiler = strtrim(opts.compiler);
o.compiler = opts.compiler;
end
if opts.showOutput
status = system([opts.compiler ' ' options middle o.fileName], echo);
else
[status, junk] = system([opts.compiler ' -interaction=batchmode ' options middle o.fileName]);
end
[junk, rfn, junk] = fileparts(o.fileName);
if status ~= 0
error(['@report.compile: There was an error in compiling ' rfn '.pdf.' ...
' ' compiler ' returned the error code: ' num2str(status)]);
end
if o.showOutput || opts.showOutput
fprintf(1, 'Done.\n');
disp('Your compiled report is located here:');
disp([' ' pwd filesep rfn '.pdf']);
end
if opts.showReport && ~isoctave
open([pwd filesep rfn '.pdf']);
end
end

View File

@ -1,32 +0,0 @@
function display(o)
%function display(o)
% Display a Report object
%
% INPUTS
% o [report] report object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
display_reporting_object(o);
end

View File

@ -1,32 +0,0 @@
function n = numPages(o)
%function n = numPages(o)
% return the number of pages currently in the report
%
% INPUTS
% o [report] report object
%
% OUTPUTS
% n [integer] number of pages in the report object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
n = length(o.pages);
end

View File

@ -1,93 +0,0 @@
function o = report(varargin)
%function o = report(varargin)
% Report Class Constructor
%
% INPUTS
% varargin 0 args : empty report object
% 1 arg : must be report object (return a copy of arg)
% > 1 args: option/value pairs (see structure below for options)
%
% OUTPUTS
% o [report] report object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
% default values
o = struct;
o.title = '';
o.orientation = 'portrait';
o.paper = 'a4';
o.margin = 2.5;
o.marginUnit = 'cm';
o.pages = {};
o.fileName = 'report.tex';
o.showDate = true;
o.compiler = '';
o.showOutput = true;
if nargin == 1
assert(isa(varargin{1}, 'report'), ['@report.report: with one arg, ' ...
'you must pass a report object']);
r = varargin{1};
return;
elseif nargin > 1
if round(nargin/2) ~= nargin/2
error(['@report.report: options must be supplied in name/value ' ...
'pairs']);
end
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
ind = find(strcmpi(optNames, pair{1}));
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@report.report: %s is not a recognized option.', pair{1});
end
end
end
% Check options provided by user
assert(ischar(o.title), '@report.report: title must be a string');
assert(ischar(o.fileName), '@report.report: fileName must be a string');
assert(ischar(o.compiler), '@report.report: compiler file must be a string');
assert(islogical(o.showDate), '@report.report: showDate must be either true or false');
assert(islogical(o.showOutput), '@report.report: showOutput must be either true or false');
assert(isfloat(o.margin) && o.margin > 0, '@report.report: margin must be a float > 0.');
valid_margin_unit = {'cm', 'in'};
assert(any(strcmp(o.marginUnit, valid_margin_unit)), ...
['@report.report: marginUnit must be one of ' strjoin(valid_margin_unit, ' ')]);
valid_paper = {'a4', 'letter'};
assert(any(strcmp(o.paper, valid_paper)), ...
['@report.report: paper must be one of ' strjoin(valid_paper, ' ')]);
valid_orientation = {'portrait', 'landscape'};
assert(any(strcmp(o.orientation, valid_orientation)), ...
['@report.report: orientation must be one of ' strjoin(valid_orientation, ' ')]);
% Create report object
o = class(o, 'report');
end

View File

@ -1,46 +0,0 @@
function B = subsasgn(A, S, V)
% function B = subsasgn(A, S, V)
% Copyright (C) 2013-2014 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/>.
B = A;
if length(S) > 1
for i=1:(length(S)-1)
B = subsref(B, S(i));
end
B = subsasgn(B, S(end), V);
B = subsasgn(A, S(1:(end-1)), B);
return
end
switch S.type
case '()'
index = S.subs{:};
assert(isnumeric(index));
B.pages{index} = V;
case '.'
switch S.subs
case fieldnames(A)
B.(S.subs) = V;
otherwise
error(['@report.subsasgn: field ' S.subs 'does not exist']);
end
otherwise
error('@report.subsasgn: syntax error');
end
end

View File

@ -1,48 +0,0 @@
function A = subsref(A, S)
%function A = subsref(A, S)
% Copyright (C) 2013-2014 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/>.
switch S(1).type
case '.'
switch S(1).subs
case fieldnames(A)
A = A.(S(1).subs);
case methods(A)
if areParensNext(S)
A = feval(S(1).subs, A, S(2).subs{:});
S = shiftS(S,1);
else
A = feval(S(1).subs, A);
end
otherwise
error(['@report.subsasgn: unknown field or method: ' S(1).subs]);
end
case '()'
A = A.pages{S(1).subs{:}};
case '{}'
error(['@report.subsasgn: ' S(1).type ' indexing not supported.']);
otherwise
error('@report.subsasgn: impossible case');
end
S = shiftS(S,1);
if length(S) >= 1
A = subsref(A, S);
end
end

View File

@ -1,98 +0,0 @@
function o = write(o)
%function o = write(o)
% Write Report object
%
% INPUTS
% o [report] report object
%
% OUTPUTS
% o [report] report object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
[fid, msg] = fopen(o.fileName, 'w');
if fid == -1
error(['@report.write: ' msg]);
end
fprintf(fid, '%% Report Object\n');
fprintf(fid, '\\documentclass[11pt]{article}\n');
fprintf(fid, '\\usepackage[%spaper,margin=%f%s', o.paper, o.margin, o.marginUnit);
if strcmpi(o.orientation, 'landscape')
fprintf(fid, ',landscape');
end
fprintf(fid, ']{geometry}\n');
fprintf(fid, '\\usepackage{pdflscape, booktabs, pgfplots, colortbl, adjustbox, multicol}\n');
fprintf(fid, '\\pgfplotsset{compat=1.5.1}');
fprintf(fid, ['\\makeatletter\n' ...
'\\def\\blfootnote{\\gdef\\@thefnmark{}\\@footnotetext}\n' ...
'\\makeatother\n']);
if isoctave && isempty(regexpi(computer, '.*apple.*', 'once'))
fprintf(fid, '\\usepackage[T1]{fontenc}\n');
fprintf(fid, '\\usepackage[utf8x]{inputenc}\n');
fprintf(fid, '\\usepackage{gnuplot-lua-tikz}\n');
end
fprintf(fid, '\\definecolor{LightCyan}{rgb}{0.88,1,1}\n');
fprintf(fid, '\\definecolor{Gray}{gray}{0.9}\n');
if o.showDate
fprintf(fid, '\\usepackage{fancyhdr, datetime}\n');
fprintf(fid, '\\newdateformat{reportdate}{\\THEDAY\\ \\shortmonthname\\ \\THEYEAR}\n');
fprintf(fid, '\\pagestyle{fancy}\n');
fprintf(fid, '\\renewcommand{\\headrulewidth}{0pt}\n');
fprintf(fid, '\\renewcommand{\\footrulewidth}{0.5pt}\n');
fprintf(fid, '\\rfoot{\\scriptsize\\reportdate\\today\\ -- \\currenttime}\n');
end
% May not need these.....
fprintf(fid, '\\renewcommand{\\textfraction}{0.05}\n');
fprintf(fid, '\\renewcommand{\\topfraction}{0.8}\n');
fprintf(fid, '\\renewcommand{\\bottomfraction}{0.8}\n');
fprintf(fid, '\\setlength{\\parindent}{0in}\n');
fprintf(fid, '\\setlength{\\tabcolsep}{1em}\n');
fprintf(fid, '\\newlength\\sectionheight\n');
fprintf(fid, '\\begin{document}\n');
fprintf(fid, '\\pgfdeclarelayer{background0}\n');
fprintf(fid, '\\pgfdeclarelayer{background1}\n');
fprintf(fid, '\\pgfsetlayers{background0,background1,main}\n');
fprintf(fid, '\\pgfplotsset{tick scale binop={\\times},\ntrim axis left}\n');
fprintf(fid, '\\centering\n');
nps = length(o.pages);
for i=1:nps
if o.showOutput
fprintf(1, 'Writing Page: %d\n', i);
end
o.pages{i}.write(fid, i);
end
fprintf(fid, '\\end{document}\n');
fprintf(fid, '%% End Report Object\n');
status = fclose(fid);
if status == -1
error('@report.write: closing %s\n', o.fileName);
end
if o.showOutput
disp('Finished Writing Report!');
end
end

View File

@ -1,32 +0,0 @@
function display(o)
%function display(o)
% Display a Report_Series object
%
% INPUTS
% o [report_series] report_series object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
display_reporting_object(o);
end

View File

@ -1,31 +0,0 @@
function s = getNameForLegend(o)
%function s = getNameForLegend(o)
% Copyright (C) 2014 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/>.
if isempty(o.data) || ~o.graphShowInLegend
% for the case when there is no data in the series
% e.g. graphVline was passed
% or when the user does not want this series shown in
% the legend
s = '';
else
assert(size(o.data,2) == 1);
s = o.data.tex{:};
end
end

View File

@ -1,27 +0,0 @@
function dd = getRange(o)
%function dd = getRange(o)
% Copyright (C) 2013 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/>.
if isempty(o.data)
dd = dates();
else
assert(size(o.data, 2) == 1);
dd = o.data.dates;
end
end

View File

@ -1,29 +0,0 @@
function s = getTexName(o)
%function s = getTexName(o)
% Copyright (C) 2013-2014 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/>.
if isempty(o.data)
% for the case when there is no data in the series
% e.g. graphVline was passed
s = '';
else
assert(size(o.data,2) == 1);
s = o.data.tex{:};
end
end

View File

@ -1,57 +0,0 @@
function o = printSeries(o, fid, dser, dates, precision)
%function printSeries(o, fid, dser, dates, precision)
% function to print a row of data, contained in dser
%
% INPUTS
% fid [int] file id
% dser [string] name of data series to be printed
% dates [dates] dates for report_series slice
% precision [float] precision with which to print the data
%
%
% OUTPUTS
% o [report_series] report_series object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2014 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/>.
dataString = sprintf('%%.%df', precision);
precision = 10^precision;
data = dser(dates);
data = setDataToZeroFromZeroTol(o, data);
for i=1:size(data,1)
fprintf(fid, '&');
if o.tableShowMarkers
if data(i) < -o.tableMarkerLimit
fprintf(fid, '\\color{%s}', o.tableNegColor);
elseif data(i) > o.tableMarkerLimit
fprintf(fid, '\\color{%s}', o.tablePosColor);
end
fprintf(fid, '[');
end
fprintf(fid, dataString, round(data(i)*precision)/precision);
if o.tableShowMarkers
fprintf(fid, ']');
end
end
end

View File

@ -1,107 +0,0 @@
function o = report_series(varargin)
%function o = report_series(varargin)
% Report_Series Class Constructor
%
% INPUTS
% varargin 0 args : empty report_series object
% 1 arg : must be report_series object (return a copy of arg)
% > 1 args: option/value pairs (see structure below for
% options)
%
% OUTPUTS
% o [report_series] report_series object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
o = struct;
o.data = '';
o.graphLegendName = '';
o.graphLineColor = 'black';
o.graphLineStyle = 'solid';
o.graphLineWidth = 0.5;
o.graphShowInLegend = true;
o.graphMarker = '';
o.graphMarkerEdgeColor = '';
o.graphMarkerFaceColor = '';
o.graphMarkerSize = 1;
o.graphMiscTikzAddPlotOptions = '';
o.graphHline = {};
o.graphVline = dates();
o.graphBar = false;
o.graphBarColor = 'black';
o.graphBarFillColor = 'black';
o.graphBarWidth = 2;
o.tableShowMarkers = false;
o.tableNegColor = 'red';
o.tablePosColor = 'blue';
o.tableMarkerLimit = 1e-4;
o.tableSubSectionHeader = '';
o.tableAlignRight = false;
o.tableRowColor = 'white';
o.tableRowIndent = 0;
o.tableDataRhs = '';
o.zeroTol = 1e-6;
if nargin == 1
assert(isa(varargin{1}, 'report_series'),['@report_series.report_series: with one arg you ' ...
'must pass a report_series object']);
o = varargin{1};
return;
elseif nargin > 1
if round(nargin/2) ~= nargin/2
error(['@report_series.report_series: options must be supplied in name/value ' ...
'pairs.']);
end
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
ind = find(strcmpi(optNames, pair{1}));
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@report_series.report_series: %s is not a recognized option.', pair{1});
end
end
end
if ~isempty(o.graphLegendName)
o.data = o.data.tex_rename(o.graphLegendName);
end
% Create report_series object
o = class(o, 'report_series');
end

View File

@ -1,28 +0,0 @@
function d = setDataToZeroFromZeroTol(o, ds)
%function d = setDataToZeroFromZeroTol(o, ds)
% Copyright (C) 2014 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/>.
d = ds.data;
stz = bsxfun(@and, ...
bsxfun(@lt, d, o.zeroTol), ...
bsxfun(@gt, d, -o.zeroTol));
if any(stz)
d(stz) = 0;
end
end

View File

@ -1,42 +0,0 @@
function B = subsasgn(A, S, V)
% function B = subsasgn(A, S, V)
% Copyright (C) 2013 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/>.
B = A;
if length(S) > 1
for i=1:(length(S)-1)
B = subsref(B, S(i));
end
B = subsasgn(B, S(end), V);
B = subsasgn(A, S(1:(end-1)), B);
return
end
switch S.type
case '.'
switch S.subs
case fieldnames(A)
B.(S.subs) = V;
otherwise
error(['@report_series.subsasgn: field ' S.subs 'does not exist']);
end
otherwise
error('@report_series.subsasgn: syntax error');
end
end

View File

@ -1,46 +0,0 @@
function A = subsref(A, S)
%function A = subsref(A, S)
% Copyright (C) 2013-2014 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/>.
switch S(1).type
case '.'
switch S(1).subs
case fieldnames(A)
A = A.(S(1).subs);
case methods(A)
if areParensNext(S)
A = feval(S(1).subs, A, S(2).subs{:});
S = shiftS(S,1);
else
A = feval(S(1).subs, A);
end
otherwise
error(['@report_series.subsref: unknown field or method: ' S(1).subs]);
end
case {'()', '{}'}
error(['@report_series.subsref: ' S(1).type ' indexing not supported.']);
otherwise
error('@report_series.subsref: impossible case')
end
S = shiftS(S,1);
if length(S) >= 1
A = subsref(A, S);
end
end

View File

@ -1,145 +0,0 @@
function o = writeSeriesForGraph(o, fid, xrange)
%function o = writeSeriesForGraph(o, fid, xrange)
% Print a TikZ line
%
% INPUTS
% o [report_series] series object
% xrange [dates] range of x values for line
%
% OUTPUTS
% NONE
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2014 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/>.
%% Validate options provided by user
if isempty(o.graphVline) && isempty(o.graphHline)
assert(~isempty(o.data) && isdseries(o.data), ['@report_series.writeSeriesForGraph: must ' ...
'provide data as a dseries']);
end
assert(ischar(o.graphMiscTikzAddPlotOptions), ['@report_series.writeSeriesForGraph: ' ...
'graphMiscTikzAddPlotOptions file must be a string']);
assert(islogical(o.graphShowInLegend), ['@report_series.writeSeriesForGraph: ' ...
'graphShowInLegend must be either true or false']);
% Line
assert(ischar(o.graphLineColor), '@report_series.writeSeriesForGraph: graphLineColor must be a string');
assert(ischar(o.graphLineStyle), '@report_series.writeSeriesForGraph: graphLineStyle must be a string');
assert(isfloat(o.graphLineWidth) && o.graphLineWidth > 0, ...
'@report_series.writeSeriesForGraph: graphLineWidth must be a positive number');
% Bar
assert(islogical(o.graphBar), '@report_series.writeSeriesForGraph: graphBar must be either true or false');
assert(ischar(o.graphBarColor), '@report_series.writeSeriesForGraph: graphBarColor must be a string');
assert(ischar(o.graphBarFillColor), '@report_series.writeSeriesForGraph: graphBarFillColor must be a string');
assert(isfloat(o.graphBarWidth) && o.graphBarWidth > 0, ...
'@report_series.writeSeriesForGraph: graphbarWidth must be a positive number');
% GraphMarker
valid_graphMarker = {'x', '+', '-', '|', 'o', 'asterisk', 'star', '10-pointed star', 'oplus', ...
'oplus*', 'otimes', 'otimes*', 'square', 'square*', 'triangle', 'triangle*', 'diamond', ...
'diamond*', 'halfdiamond*', 'halfsquare*', 'halfsquare right*', ...
'halfsquare left*','Mercedes star','Mercedes star flipped','halfcircle',...
'halfcircle*','pentagon','pentagon star'};
assert(isempty(o.graphMarker) || any(strcmp(o.graphMarker, valid_graphMarker)), ...
['@report_series.writeSeriesForGraph: graphMarker must be one of ' strjoin(valid_graphMarker)]);
assert(ischar(o.graphMarkerEdgeColor), '@report_series.writeSeriesForGraph: graphMarkerEdgeColor must be a string');
assert(ischar(o.graphMarkerFaceColor), '@report_series.writeSeriesForGraph: graphMarkerFaceColor must be a string');
assert(isfloat(o.graphMarkerSize) && o.graphMarkerSize > 0, ...
'@report_series.writeSeriesForGraph: graphMarkerSize must be a positive number');
% Marker & Line
assert(~(strcmp(o.graphLineStyle, 'none') && isempty(o.graphMarker)), ['@report_series.writeSeriesForGraph: ' ...
'you must provide at least one of graphLineStyle and graphMarker']);
% Validate graphVline
assert(isempty(o.graphVline) || (isdates(o.graphVline) && o.graphVline.ndat == 1), ...
'@report_series.writeSeriesForGraph: graphVline must be a dates of size one');
assert(isempty(o.graphHline) || isnumeric(o.graphHline), ...
'@report_series.writeSeriesForGraph: graphHline must a single numeric value');
% Zero tolerance
assert(isfloat(o.zeroTol), '@report_series.write: zeroTol must be a float');
%% graphVline && graphHline
if ~isempty(o.graphVline)
fprintf(fid, '%%Vertical Line\n\\begin{pgfonlayer}{background1}\n\\draw');
writeLineOptions(o, fid);
stringsdd = strings(xrange);
x = find(strcmpi(date2string(o.graphVline), stringsdd));
fprintf(fid, ['(axis cs:%d,\\pgfkeysvalueof{/pgfplots/ymin}) -- (axis ' ...
'cs:%d,\\pgfkeysvalueof{/pgfplots/ymax});\n\\end{pgfonlayer}\n'], ...
x, x);
end
if ~isempty(o.graphHline)
fprintf(fid, '%%Horizontal Line\n\\begin{pgfonlayer}{background1}\n\\addplot');
writeLineOptions(o, fid);
fprintf(fid, ['coordinates {(\\pgfkeysvalueof{/pgfplots/xmin},%f)' ...
'(\\pgfkeysvalueof{/pgfplots/xmax},%f)};\n\\end{pgfonlayer}\n'], ...
o.graphHline, o.graphHline);
end
if ~isempty(o.graphVline) || ~isempty(o.graphHline)
% return since the code below assumes that o.data exists
return
end
%%
if isempty(xrange) || all(xrange == o.data.dates)
ds = o.data;
else
ds = o.data(xrange);
end
thedata = setDataToZeroFromZeroTol(o, ds);
fprintf(fid, '%%series %s\n\\addplot', o.data.name{:});
writeLineOptions(o, fid);
fprintf(fid,'\ntable[row sep=crcr]{\nx y\\\\\n');
for i=1:ds.dates.ndat
fprintf(fid, '%d %f\\\\\n', i, thedata(i));
end
fprintf(fid,'};\n');
end
function writeLineOptions(o, fid)
if o.graphBar
fprintf(fid, '[ybar,ybar legend,color=%s,fill=%s,line width=%fpt',...
o.graphBarColor, o.graphBarFillColor, o.graphBarWidth);
else
fprintf(fid, '[color=%s,%s,line width=%fpt,line join=round',...
o.graphLineColor, o.graphLineStyle, o.graphLineWidth);
if ~isempty(o.graphMarker)
if isempty(o.graphMarkerEdgeColor)
o.graphMarkerEdgeColor = o.graphLineColor;
end
if isempty(o.graphMarkerFaceColor)
o.graphMarkerFaceColor = o.graphLineColor;
end
fprintf(fid, ',mark=%s,mark size=%f,every mark/.append style={draw=%s,fill=%s}',...
o.graphMarker,o.graphMarkerSize,o.graphMarkerEdgeColor,o.graphMarkerFaceColor);
end
end
if ~isempty(o.graphMiscTikzAddPlotOptions)
fprintf(fid, ',%s', o.graphMiscTikzAddPlotOptions);
end
fprintf(fid,']');
end

View File

@ -1,105 +0,0 @@
function o = writeSeriesForTable(o, fid, dates, precision, ncols, rowcolor)
%function o = writeSeriesForTable(o, fid, dates, precision, ncols, rowcolor)
% Write Table Row
%
% INPUTS
% o [report_series] report_series object
% fid [int] file id
% dates [dates] dates for report_series slice
% precision [float] precision with which to print the data
% ncols [int] total number of columns in table
% rowcolor [string] string to color this row
%
%
% OUTPUTS
% o [report_series] report_series object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
%% Validate options passed to function
assert(fid ~= -1);
for i=1:length(dates)
assert(isdates(dates{i}));
end
assert(isint(precision));
%% Validate options provided by user
assert(ischar(o.tableSubSectionHeader), '@report_series.writeSeriesForTable: tableSubSectionHeader must be a string');
if isempty(o.tableSubSectionHeader)
assert(~isempty(o.data) && isdseries(o.data), ...
'@report_series.writeSeriesForTable: must provide data as a dseries');
if ~isempty(o.tableDataRhs)
assert(~isempty(o.tableDataRhs) && isdseries(o.tableDataRhs), ...
'@report_series.writeSeriesForTable: must provide tableDataRhs as a dseries');
assert(iscell(dates) && length(dates) == 2, ...
'@report_series.writeSeriesForTable: must provide second range with tableDataRhs');
end
end
assert(ischar(o.tableNegColor), '@report_series.writeSeriesForTable: tableNegColor must be a string');
assert(ischar(o.tablePosColor), '@report_series.writeSeriesForTable: tablePosColor must be a string');
assert(ischar(o.tableRowColor), '@report_series.writeSeriesForTable: tableRowColor must be a string');
assert(isint(o.tableRowIndent) && o.tableRowIndent >= 0, ...
'@report_series.writeSeriesForTable: tableRowIndent must be an integer >= 0');
assert(islogical(o.tableShowMarkers), '@report_series.writeSeriesForTable: tableShowMarkers must be true or false');
assert(islogical(o.tableAlignRight), '@report_series.writeSeriesForTable: tableAlignRight must be true or false');
assert(isfloat(o.tableMarkerLimit), '@report_series.writeSeriesForTable: tableMarkerLimit must be a float');
%% Write Output
fprintf(fid, '%% Table Row (report_series)\n');
if ~isempty(o.tableRowColor) && ~strcmpi(o.tableRowColor, 'white')
fprintf(fid, '\\rowcolor{%s}', o.tableRowColor);
elseif ~isempty(rowcolor)
fprintf(fid, '\\rowcolor{%s}', rowcolor);
else
fprintf(fid, '\\rowcolor{%s}', o.tableRowColor);
end
if ~isempty(o.tableSubSectionHeader)
fprintf(fid, '\\textbf{%s}', o.tableSubSectionHeader);
for i=1:ncols-1
fprintf(fid, ' &');
end
fprintf(fid, '\\\\%%\n');
return;
end
if o.tableAlignRight
fprintf(fid, '\\multicolumn{1}{r}{');
end
if o.tableRowIndent == 0
fprintf(fid, '\\noindent');
else
for i=1:o.tableRowIndent
fprintf(fid,'\\indent');
end
end
fprintf(fid, ' %s', o.data.tex{:});
if o.tableAlignRight
fprintf(fid, '}');
end
printSeries(o, fid, o.data, dates{1}, precision);
if ~isempty(o.tableDataRhs)
printSeries(o, fid, o.tableDataRhs, dates{2}, precision);
end
fprintf(fid, '\\\\%%\n');
end

View File

@ -1,23 +0,0 @@
function ymax = ymax(o, dd)
%function ymax = ymax(o, dd)
% Copyright (C) 2014 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/>.
assert(~isempty(o.data) && size(o.data, 2) == 1);
ymax = max(o.data(dd).data);
end

View File

@ -1,23 +0,0 @@
function ymin = ymin(o, dd)
%function ymin = ymin(o, dd)
% Copyright (C) 2014 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/>.
assert(~isempty(o.data) && size(o.data, 2) == 1);
ymin = min(o.data(dd).data);
end

View File

@ -1,22 +0,0 @@
function o = addSeries(o, varargin)
% function o = addSeries(o, varargin)
% Copyright (C) 2013-2014 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/>.
o.series{end+1} = report_series(varargin{:});
end

View File

@ -1,32 +0,0 @@
function display(o)
%function display(o)
% Display a Report_Table object
%
% INPUTS
% o [report_table] report_table object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
display_reporting_object(o);
end

View File

@ -1,145 +0,0 @@
function o = report_table(varargin)
%function o = report_table(varargin)
% Report_Table Class Constructor
%
% INPUTS
% 0 args => empty report_table
% 1 arg (report_table class) => copy object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
o = struct;
o.tableDirName = 'tmpRepDir';
o.tableName = '';
o.series = {};
o.title = {''};
titleFormatDefalut = {'\large'};
o.titleFormat = titleFormatDefalut;
o.showHlines = false;
o.showVlines = false;
o.vlineAfter = '';
o.vlineAfterEndOfPeriod = false;
o.data = '';
o.seriesToUse = '';
o.range = {};
o.precision = 1;
o.writeCSV = false;
o.highlightRows = {''};
if nargin == 1
assert(isa(varargin{1}, 'report_table'),['With one arg to Report_Table constructor, ' ...
'you must pass a report_table object']);
o = varargin{1};
return;
elseif nargin > 1
if round(nargin/2) ~= nargin/2
error(['Options to Report_Table constructor must be supplied in name/value ' ...
'pairs.']);
end
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
ind = find(strcmpi(optNames, pair{1}));
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('%s is not a recognized option to the Report_Table constructor.', pair{1});
end
end
end
if ~iscell(o.range)
o.range = {o.range};
end
if isdates(o.vlineAfter)
o.vlineAfter = {o.vlineAfter};
end
% Check options provided by user
if ischar(o.title)
o.title = {o.title};
end
if ischar(o.titleFormat)
o.titleFormat = {o.titleFormat};
end
if length(o.title) ~= length(o.titleFormat)
o.titleFormat = repmat(titleFormatDefalut, 1, length(o.title));
end
assert(islogical(o.showHlines), '@report_table.report_table: showHlines must be true or false');
assert(islogical(o.showVlines), '@report_table.report_table: showVlines must be true or false');
assert(isint(o.precision), '@report_table.report_table: precision must be an int');
assert(isempty(o.range) || length(o.range) <=2 && allCellsAreDatesRange(o.range), ...
['@report_table.report_table: range is specified as a dates range, e.g. ' ...
'''dates(''1999q1''):dates(''1999q3'')''.']);
assert(isempty(o.data) || isdseries(o.data), ...
'@report_table.report_table: data must be a dseries');
assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ...
'@report_table.report_table: seriesToUse must be a cell array of string(s)');
assert(isempty(o.vlineAfter) || allCellsAreDates(o.vlineAfter), ...
'@report_table.report_table: vlineAfter must be a dates');
if o.showVlines
o.vlineAfter = '';
end
assert(islogical(o.vlineAfterEndOfPeriod), ...
'@report_table.report_table: vlineAfterEndOfPeriod must be true or false');
assert(iscellstr(o.title), ...
'@report_table.report_table: title must be a cell array of string(s)');
assert(iscellstr(o.titleFormat), ...
'@report_table.report_table: titleFormat must be a cell array of string(s)');
assert(ischar(o.tableName), '@report_table.report_table: tableName must be a string');
assert(ischar(o.tableDirName), '@report_table.report_table: tableDirName must be a string');
assert(islogical(o.writeCSV), '@report_table.report_table: writeCSV must be either true or false');
assert(iscellstr(o.highlightRows), '@report_table.report_table: highlightRowsmust be a cell string');
% using o.seriesToUse, create series objects and put them in o.series
if ~isempty(o.data)
if isempty(o.seriesToUse)
for i=1:o.data.vobs
o.series{end+1} = report_series('data', o.data{o.data.name{i}});
end
else
for i=1:length(o.seriesToUse)
o.series{end+1} = report_series('data', o.data{o.seriesToUse{i}});
end
end
end
o = rmfield(o, 'seriesToUse');
o = rmfield(o, 'data');
if ~exist(o.tableDirName, 'file')
mkdir(o.tableDirName);
end
% Create report_table object
o = class(o, 'report_table');
end

View File

@ -1,45 +0,0 @@
function B = subsasgn(A, S, V)
% function B = subsasgn(A, S, V)
% Copyright (C) 2013 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/>.
B = A;
if length(S) > 1
for i=1:(length(S)-1)
B = subsref(B, S(i));
end
B = subsasgn(B, S(end), V);
B = subsasgn(A, S(1:(end-1)), B);
return
end
switch S.type
case '.'
switch S.subs
case fieldnames(A)
B.(S.subs) = V;
otherwise
error(['@report_table.subsasgn: field ' S.subs 'does not exist in the report_table class'])
end
case '{}'
assert(isint(S.subs{1}));
B{S.subs{1}} = V;
otherwise
error('@report_table.subsasgn: syntax error')
end
end

View File

@ -1,46 +0,0 @@
function A = subsref(A, S)
%function A = subsref(A, S)
% Copyright (C) 2013-2014 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/>.
switch S(1).type
case '.'
switch S(1).subs
case fieldnames(A)
A = A.(S(1).subs);
case methods(A)
if areParensNext(S)
A = feval(S(1).subs, A, S(2).subs{:});
S = shiftS(S,1);
else
A = feval(S(1).subs, A);
end
otherwise
error(['@report_table.subsref: unknown field or method: ' S(1).subs]);
end
case {'()', '{}'}
error(['@report_table.subsref: ' S(1).type ' indexing not supported.']);
otherwise
error('@report_table.subsref: subsref.m impossible case')
end
S = shiftS(S,1);
if length(S) >= 1
A = subsref(A, S);
end
end

View File

@ -1,39 +0,0 @@
function o = write(o, fid, pg, sec, row, col)
%function o = write(o, fid, pg, sec, row, col)
% Write a Table object
%
% INPUTS
% o [table] table object
% fid [integer] file id
% pg [integer] this page number
% sec [integer] this section number
% row [integer] this row number
% col [integer] this col number
%
% OUTPUTS
% o [table] table object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
assert(fid ~= -1);
o = writeTableFile(o, pg, sec, row, col);
fprintf(fid, '\\input{%s}', o.tableName);
end

View File

@ -1,200 +0,0 @@
function o = writeTableFile(o, pg, sec, row, col)
%function o = writeTableFile(o, pg, sec, row, col)
% Write a Report_Table object
%
% INPUTS
% o [report_table] report_table object
% pg [integer] this page number
% sec [integer] this section number
% row [integer] this row number
% col [integer] this col number
%
% OUTPUTS
% o [report_table] report_table object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
ne = length(o.series);
if ne == 0
warning('@report_table.write: no series to plot, returning');
return;
end
if isempty(o.tableName)
o.tableName = sprintf('%s/table_pg%d_sec%d_row%d_col%d.tex', o.tableDirName, pg, sec, row, col);
else
o.tableName = [o.tableDirName '/' o.tableName];
end
[fid, msg] = fopen(o.tableName, 'w');
if fid == -1
error(['@report_table.writeTableFile: ' msg]);
end
%number of left-hand columns, 1 until we allow the user to group data,
% e.g.: GDP Europe
% GDP France
% GDP Germany
% this example would be two lh columns, with GDP Europe spanning both
nlhc = 1;
if isempty(o.range)
dates = getMaxRange(o.series);
o.range = {dates};
else
dates = o.range{1};
end
ndates = dates.ndat;
fprintf(fid, '%% Report_Table Object\n');
fprintf(fid, '\\setlength{\\parindent}{6pt}\n');
fprintf(fid, '\\setlength{\\tabcolsep}{4pt}\n');
fprintf(fid, '\\begin{tabular}{@{}l');
for i=1:ndates
fprintf(fid, 'r');
if o.showVlines
fprintf(fid, '|');
elseif o.vlineAfterEndOfPeriod && dates(i).time(2) == dates(i).freq
fprintf(fid, '|');
elseif ~isempty(o.vlineAfter)
for j=1:length(o.vlineAfter)
if dates(i) == o.vlineAfter{j}
fprintf(fid, '|');
end
end
end
end
datedata = dates.time;
years = unique(datedata(:, 1));
if length(o.range) > 1
rhscols = strings(o.range{2});
if o.range{2}.freq == 1
rhscols = strrep(rhscols, 'Y', '');
end
else
rhscols = {};
end
for i=1:length(rhscols)
fprintf(fid, 'r');
if o.showVlines
fprintf(fid, '|');
end
end
nrhc = length(rhscols);
ncols = ndates+nlhc+nrhc;
fprintf(fid, '@{}}%%\n');
for i=1:length(o.title)
if ~isempty(o.title{i})
fprintf(fid, '\\multicolumn{%d}{c}{%s %s}\\\\\n', ...
ncols, o.titleFormat{i}, o.title{i});
end
end
fprintf(fid, '\\toprule%%\n');
% Column Headers
thdr = num2cell(years, size(years, 1));
if dates.freq == 1
for i=1:size(thdr, 1)
fprintf(fid, ' & %d', thdr{i, 1});
end
for i=1:length(rhscols)
fprintf(fid, ' & %s', rhscols{i});
end
else
thdr{1, 2} = datedata(:, 2)';
if size(thdr, 1) > 1
for i=2:size(thdr, 1)
split = find(thdr{i-1, 2} == dates.freq, 1, 'first');
assert(~isempty(split), '@report_table.writeTableFile: Shouldn''t arrive here');
thdr{i, 2} = thdr{i-1, 2}(split+1:end);
thdr{i-1, 2} = thdr{i-1, 2}(1:split);
end
end
for i=1:size(thdr, 1)
fprintf(fid, ' & \\multicolumn{%d}{c}{%d}', size(thdr{i,2}, 2), thdr{i,1});
end
for i=1:length(rhscols)
fprintf(fid, ' & %s', rhscols{i});
end
fprintf(fid, '\\\\\n');
switch dates.freq
case 4
sep = 'Q';
case 12
sep = 'M';
case 52
sep = 'W';
otherwise
error('@report_table.writeTableFile: Invalid frequency.');
end
for i=1:size(thdr, 1)
period = thdr{i, 2};
for j=1:size(period, 2)
fprintf(fid, ' & \\multicolumn{1}{c');
if o.showVlines
fprintf(fid, '|');
elseif o.vlineAfterEndOfPeriod && j == size(period, 2)
fprintf(fid, '|');
elseif ~isempty(o.vlineAfter)
for k=1:length(o.vlineAfter)
if o.vlineAfter{k}.time(1) == thdr{i} && ...
o.vlineAfter{k}.time(2) == period(j)
fprintf(fid, '|');
end
end
end
fprintf(fid, '}{%s%d}', sep, period(j));
end
end
end
fprintf(fid, '\\\\[-2pt]%%\n');
fprintf(fid, '\\hline%%\n');
fprintf(fid, '%%\n');
% Write Report_Table Data
if o.writeCSV
csvseries = dseries();
end
for i=1:ne
o.series{i}.writeSeriesForTable(fid, o.range, o.precision, ncols, o.highlightRows{mod(i,length(o.highlightRows))+1});
if o.writeCSV
if isempty(o.series{i}.tableSubSectionHeader)
csvseries = [csvseries ...
o.series{i}.data(dates).set_names([...
num2str(i) '_' ...
o.series{i}.data.name{:}])];
end
end
if o.showHlines
fprintf(fid, '\\hline\n');
end
end
if o.writeCSV
csvseries.save(strrep(o.tableName, '.tex', ''), 'csv');
end
fprintf(fid, '\\bottomrule\n');
fprintf(fid, '\\end{tabular}\\setlength{\\parindent}{0pt}\n \\par \\medskip\n\n');
fprintf(fid, '%% End Report_Table Object\n');
if fclose(fid) == -1
error('@report_table.writeTableFile: closing %s\n', o.filename);
end
end

View File

@ -1,38 +0,0 @@
function o = addGraph(o, varargin)
%function o = addGraph(o, varargin)
% Add a graph to the Cell Array of graphs in the report
%
% INPUTS
% 1 args => add empty graph
% 2 args => add given graph
% 3 args => add graph at index
%
% OUTPUTS
% updated section object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
for i=1:length(o.elements)
assert(~isa(o.elements{i}, 'paragraph'), ...
'@addGraph: A Section that contains a Paragraph cannot contain a Graph');
end
o.elements{end+1} = graph(varargin{:});
end

View File

@ -1,42 +0,0 @@
function o = addParagraph(o, varargin)
%function o = addParagraph(o, varargin)
% Add a paragraph to the Cell Array of elements in this section
%
% INPUTS
% 1 args => add empty paragraph
% 2 args => add given paragraph
% 3 args => add paragraph at index
%
% OUTPUTS
% updated page object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2014 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/>.
assert(o.cols == 1, ...
['@addParagraph: you can only add a paragraph to a Section that ' ...
'contains one column']);
for i=1:length(o.elements)
assert(isa(o.elements{i}, 'paragraph'), ...
['@addParagraph: you can only add a paragraph to a Section that ' ...
'contains only paragraphs']);
end
o.elements{end+1} = paragraph(varargin{:});
end

View File

@ -1,38 +0,0 @@
function o = addTable(o, varargin)
%function o = addTable(o, varargin)
% Add a report_table to the Cell Array of report_tables in the report
%
% INPUTS
% 1 args => add empty report_table
% 2 args => add given report_table
% 3 args => add report_table at index
%
% OUTPUTS
% updated section object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
for i=1:length(o.elements)
assert(~isa(o.elements{i}, 'paragraph'), ...
'@addTable: A Section that contains a Paratable cannot contain a Table');
end
o.elements{end+1} = report_table(varargin{:});
end

View File

@ -1,37 +0,0 @@
function o = addVspace(o, varargin)
%function o = addVspace(o, varargin)
% Add a vspace to the Cell Array of vspaces in the report
%
% INPUTS
% 1 args => add empty vspace
% 2 args => add given vspace
%
% OUTPUTS
% updated section object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
for i=1:length(o.elements)
assert(~isa(o.elements{i}, 'paragraph'), ...
'@addVspace: A Section that contains a Paragraph cannot contain a Vspace');
end
o.elements{end+1} = vspace(varargin{:});
end

View File

@ -1,32 +0,0 @@
function display(o)
%function display(o)
% Display a Section object
%
% INPUTS
% o [section] section object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
display_reporting_object(o);
end

View File

@ -1,35 +0,0 @@
function lastIndex = end(o, k, n)
% function lastIndex = end(o, k, n)
% End keyword
%
% INPUTS
% o [section] section object
% k [integer] index where end appears
% n [integer] number of indices
%
% OUTPUTS
% lastIndex [integer] last section index
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013 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/>.
assert(k==1 && n==1, '@section/end: section only has one dimension');
lastIndex = numElements(o);
end

View File

@ -1,22 +0,0 @@
function n = numElements(o)
% function n = numElements(o)
% Copyright (C) 2013-2014 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/>.
n = length(o.elements);
end

View File

@ -1,60 +0,0 @@
function o = section(varargin)
%function o = section(varargin)
% Section produces a latex minipage
% Copyright (C) 2013-2014 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/>.
o = struct;
o.elements = {};
o.cols = 1;
o.height = '';
if nargin == 1
assert(isa(varargin{1}, 'section'),['With one arg to Section constructor, ' ...
'you must pass a section object']);
o = varargin{1};
return;
elseif nargin > 1
if round(nargin/2) ~= nargin/2
error(['@section.section: options must be supplied in name/value ' ...
'pairs.']);
end
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
ind = find(strcmpi(optNames, pair{1}));
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@section.section: %s is not a recognized option.', pair{1});
end
end
end
% Check options provided by user
assert(isint(o.cols), '@section.section: cols must be an integer');
assert(isempty(o.height) || ischar(o.height), ...
'@section.section: cols must be a string');
% Create section object
o = class(o, 'section');
end

View File

@ -1,50 +0,0 @@
function B = subsasgn(A, S, V)
% function B = subsasgn(A, S, V)
% Copyright (C) 2013-2014 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/>.
B = A;
if length(S) > 1
for i=1:(length(S)-1)
B = subsref(B, S(i));
end
B = subsasgn(B, S(end), V);
B = subsasgn(A, S(1:(end-1)), B);
return
end
switch S.type
case '()'
index = S.subs{:};
assert(isnumeric(index));
B.elements{index} = V;
case '{}'
index = S.subs{:};
assert(isnumeric(index));
B{index} = V;
case '.'
switch S.subs
case fieldnames(A)
B.(S.subs) = V;
otherwise
error(['@section.subsasgn: field ' S.subs 'does not exist']);
end
otherwise
error('@section.subsasgn: syntax error');
end
end

View File

@ -1,48 +0,0 @@
function A = subsref(A, S)
%function A = subsref(A, S)
% Copyright (C) 2013-2014 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/>.
switch S(1).type
case '.'
switch S(1).subs
case fieldnames(A)
A = A.(S(1).subs);
case methods(A)
if areParensNext(S)
A = feval(S(1).subs, A, S(2).subs{:});
S = shiftS(S,1);
else
A = feval(S(1).subs, A);
end
otherwise
error(['@section.subsref: unknown field or method: ' S(1).subs]);
end
case '()'
A = A.elements{S(1).subs{:}};
case '{}'
error(['@section.subsref: ' S(1).type ' indexing not supported.']);
otherwise
error('@section.subsref: impossible case')
end
S = shiftS(S,1);
if length(S) >= 1
A = subsref(A, S);
end
end

View File

@ -1,89 +0,0 @@
function o = write(o, fid, pg, sec)
%function o = write(o, fid, pg, sec)
% Write Section object
%
% INPUTS
% o [section] section object
% fid [integer] file id
% pg [integer] this page number
% sec [integer] this section number
%
% OUTPUTS
% o [section] section object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
assert(fid ~= -1);
fprintf(fid, '%% Section Object\n');
if ~isempty(o.height)
fprintf(fid, '\\setlength\\sectionheight{%s}%%\n', o.height);
end
fprintf(fid, '\\maxsizebox{\\textwidth}{');
if isempty(o.height)
fprintf(fid, '!');
else
fprintf(fid, '\\sectionheight');
end
fprintf(fid, '}{%%\n');
fprintf(fid, '\\begin{tabular}[t]{');
for i=1:o.cols
if ~isa(o.elements{1}, 'paragraph')
% if one element is a paragraph, they all are
% due to check in add*.m functions
fprintf(fid, 'l');
else
fprintf(fid, 'c');
end
end
fprintf(fid, '}\n');
ne = numElements(o);
row = 1;
col = 1;
for i=1:ne
if isa(o.elements{i}, 'vspace')
o.elements{i}.write(fid);
fprintf(fid, '\\\\\n');
if col ~= o.cols
fprintf(fid, '\\end{tabular}}\\\\\n');
fprintf(fid, '%% End Section Object\n\n');
return;
end
else
if isa(o.elements{i}, 'paragraph')
o.elements{i}.write(fid);
else
o.elements{i}.write(fid, pg, sec, row, col);
end
if col ~= o.cols
fprintf(fid, ' & ');
col = col + 1;
else
fprintf(fid, '\\\\\n');
row = row + 1;
col = 1;
end
end
end
fprintf(fid, '\\end{tabular}}\\\\\n');
fprintf(fid, '%% End Section Object\n\n');
end

View File

@ -1,32 +0,0 @@
function display(o)
%function display(o)
% Display a Vspace object
%
% INPUTS
% o [vspace] vspace object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
display_reporting_object(o);
end

View File

@ -1,49 +0,0 @@
function B = subsasgn(A, S, V)
% function B = subsasgn(A, S, V)
% Copyright (C) 2013 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/>.
B = A;
if length(S) > 1
for i=1:(length(S)-1)
B = subsref(B, S(i));
end
B = subsasgn(B, S(end), V);
B = subsasgn(A, S(1:(end-1)), B);
return
end
switch S.type
case '()'
index = S.subs{:};
assert(isnumeric(index));
B{index} = V;
case '.'
switch S.subs
case fieldnames(A)
B.(S.subs) = V;
otherwise
error(['@vspace.subsasgn: field ' S.subs 'does not exist']);
end
case '{}'
assert(isint(S.subs{1}));
B{S.subs{1}} = V;
otherwise
error('@vspace.subsasgn: syntax error');
end
end

View File

@ -1,48 +0,0 @@
function A = subsref(A, S)
%function A = subsref(A, S)
% Copyright (C) 2013-2014 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/>.
switch S(1).type
case '.'
switch S(1).subs
case fieldnames(A)
A = A.(S(1).subs);
case methods(A)
if areParensNext(S)
A = feval(S(1).subs, A, S(2).subs{:});
S = shiftS(S,1);
else
A = feval(S(1).subs, A);
end
otherwise
error(['@vspace.subsref: unknown field or method: ' S(1).subs]);
end
case '()'
A = getSections(A, S(1).subs{:});
case '{}'
error(['@vspace.subsref: ' S(1).type ' indexing not supported.']);
otherwise
error('@vspace.subsref: impossible case')
end
S = shiftS(S,1);
if length(S) >= 1
A = subsref(A, S);
end
end

View File

@ -1,67 +0,0 @@
function o = vspace(varargin)
%function o = vspace(varargin)
% Vspace Class Constructor
%
% INPUTS
% 0 args => empty vspace
% 1 arg (vspace class) => copy object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
o = struct;
o.number = 1;
o.hline = 0;
if nargin == 1
assert(isa(varargin{1}, 'vspace'), ['@vspace.vspace: with one arg to Vspace ' ...
'constructor, you must pass a vspace object']);
o = varargin{1};
return;
elseif nargin > 1
if round(nargin/2) ~= nargin/2
error(['@vspace.vspace: options must be supplied in name/value ' ...
'pairs.']);
end
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
ind = find(strcmpi(optNames, pair{1}));
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@vspace.vspace: %s is not a recognized option.', pair{1});
end
end
end
% Check options provided by user
assert(isint(o.number), '@vspace.vspace: number must be an integer');
assert(isint(o.hline), '@vspace.vspace: hline must be an integer');
% Create vspace object
o = class(o, 'vspace');
end

View File

@ -1,44 +0,0 @@
function o = write(o, fid)
%function o = write(o, fid)
% Write a Vspace object
%
% INPUTS
% o [vspace] vspace object
% fid [integer] file id
%
% OUTPUTS
% o [vspace] vspace object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
assert(fid ~= -1);
for i=1:o.number
fprintf(fid, ' \\par \\medskip ');
end
if o.hline > 0
fprintf(fid, '\\\\\n');
for i=1:o.hline
fprintf(fid, '\\midrule');
end
end
end

View File

@ -1,39 +0,0 @@
function tf = allCellsAreDates(dcell)
%function tf = allCellsAreDates(dcell)
% Determines if all the elements of dcell are dates objects
%
% INPUTS
% dcell cell of dates objects
%
% OUTPUTS
% tf true if every entry of dcell is a dates object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2014 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/>.
assert(iscell(dcell));
tf = true;
for i=1:length(dcell)
if ~isdates(dcell{i})
tf = false;
return;
end
end
end

View File

@ -1,39 +0,0 @@
function tf = allCellsAreDatesRange(dcell)
%function tf = allCellsAreDatesRange(dcell)
% Determines if all the elements of dcell are a range of dates
%
% INPUTS
% dcell cell of dates
%
% OUTPUTS
% tf true if every entry of dcell is a range of dates
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2014 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/>.
assert(iscell(dcell));
tf = true;
for i=1:length(dcell)
if ~(isdates(dcell{i}) && dcell{i}.ndat >= 2)
tf = false;
return;
end
end
end

View File

@ -1,26 +0,0 @@
function tf = areParensNext(S)
%function tf = areParensNext(S)
% Copyright (C) 2013 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/>.
if length(S) > 1 && strcmp(S(2).type, '()')
tf = true;
else
tf = false;
end
end

View File

@ -1,95 +0,0 @@
function display_reporting_object(o)
%function display_reporting_object(o)
% Display a Reporting Object
% i.e., one of: graph
% page
% report
% report_series
% report_table
% section
% vspace
%
% INPUTS
% o [object] reporting object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 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/>.
fprintf('\n%s Object = \n\n', upper(class(o)));
fields = fieldnames(o);
for i=1:length(fields)
fprintf(' %s: ', fields{i});
val = o.(fields{i});
if iscell(val)
fprintf('{');
for j=1:length(val)
if ischar(val{j});
fprintf('''%s''', val{j});
if j~=length(val)
fprintf(', ');
end
else
if strcmp(fields{i}, 'pages') || strcmp(fields{i}, 'sections')
fprintf('%d', length(val));
break;
else
fprintf('fix this');
end
end
end
fprintf('}');
elseif ischar(val)
fprintf('''%s''', val);
elseif isnumeric(val)
fprintf('%s', num2str(val));
elseif islogical(val)
if val
fprintf('true');
else
fprintf('false');
end
elseif isobject(val)
if isdates(val)
if isempty(val)
fprintf('<dates: empty>');
else
fprintf('<dates: %s, ..., %s>', ...
date2string(val(1)), date2string(val(end)));
end
elseif isdseries(val)
if numel(val) == 1
fprintf('<dseries: %s>', val.name{1});
else
fprintf('%s', class(val));
end
else
cl = class(val);
fprintf('%d', val.(['num' upper(cl(1)) cl(2:end)]));
end
else
fprintf('fix this');
end
fprintf('\n');
end
fprintf('\n');
end

View File

@ -1,36 +0,0 @@
function dd = getMaxRange(cellser)
% function dd = getMaxRange(cellser)
% Copyright (C) 2013-2014 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/>.
ddmin = dates();
ddmax = dates();
ne = length(cellser);
for i=1:ne
ddt = cellser{i}.getRange();
if ~isempty(ddt)
if isempty(ddmin)
ddmin = ddt(1);
ddmax = ddt(end);
else
ddmin = min(ddt(1), ddmin);
ddmax = max(ddt(end), ddmax);
end
end
end
dd = ddmin:ddmax;