reporting: change table class name to report_table to avoid conflict with matlab function table

time-shift
Houtan Bastani 2013-10-17 16:16:30 +02:00
parent 63430a54ea
commit 1b7d2e1d10
9 changed files with 46 additions and 46 deletions

View File

@ -18,5 +18,5 @@ function e = addTable(e, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
e.objArray = e.objArray.addObj(table(varargin{:}));
e.objArray = e.objArray.addObj(report_table(varargin{:}));
end

View File

@ -30,8 +30,8 @@ function o = addSeries(o, varargin)
% 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), 'table'), ...
'@report.addSeries: you can only add a series to a table or graph object');
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{:});

View File

@ -1,9 +1,9 @@
function display(o)
%function display(o)
% Display a Table object
% Display a Report_Table object
%
% INPUTS
% o [table] table object
% o [report_table] report_table object
%
% OUTPUTS
% none

View File

@ -1,10 +1,10 @@
function o = table(varargin)
%function o = table(varargin)
% Table Class Constructor
function o = report_table(varargin)
%function o = report_table(varargin)
% Report_Table Class Constructor
%
% INPUTS
% 0 args => empty table
% 1 arg (table class) => copy object
% 0 args => empty report_table
% 1 arg (report_table class) => copy object
%
% OUTPUTS
% none
@ -49,13 +49,13 @@ o.range = {};
o.precision = 1;
if nargin == 1
assert(isa(varargin{1}, 'table'),['With one arg to Table constructor, ' ...
'you must pass a table object']);
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 Table constructor must be supplied in name/value ' ...
error(['Options to Report_Table constructor must be supplied in name/value ' ...
'pairs.']);
end
@ -68,35 +68,35 @@ elseif nargin > 1
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('%s is not a recognized option to the Table constructor.', pair{1});
error('%s is not a recognized option to the Report_Table constructor.', pair{1});
end
end
end
% Check options provided by user
assert(ischar(o.title), '@table.table: title must be a string');
assert(islogical(o.annualAverages), '@table.table: annualAverages must be true or false');
assert(islogical(o.showHlines), '@table.table: showHlines must be true or false');
assert(islogical(o.showVlines), '@table.table: showVlines must be true or false');
assert(isint(o.precision), '@table.table: precision must be an int');
assert(ischar(o.title), '@report_table.report_table: title must be a string');
assert(islogical(o.annualAverages), '@report_table.report_table: annualAverages must be true or false');
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) || (isa(o.range, 'dynDates') && o.range.ndat >= 2), ...
['@table.table: range is specified as a dynDates range, e.g. ' ...
['@report_table.report_table: range is specified as a dynDates range, e.g. ' ...
'''dynDates(''1999q1''):dynDates(''1999q3'')''.']);
assert(isempty(o.data) || isa(o.data, 'dynSeries'), ...
'@table.table: data must be a dynSeries');
'@report_table.report_table: data must be a dynSeries');
assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ...
'@table.table: seriesToUse must be a cell array of string(s)');
'@report_table.report_table: seriesToUse must be a cell array of string(s)');
assert(isempty(o.vlineAfter) || isa(o.vlineAfter, 'dynDate'), ...
'@table.table: vlineAfter must be a dynDate');
'@report_table.report_table: vlineAfter must be a dynDate');
if o.showVlines
o.vlineAfter = '';
end
assert(islogical(o.vlineAfterEndOfPeriod), ...
'@table.table: vlineAfterEndOfPeriod must be true or false');
'@report_table.report_table: vlineAfterEndOfPeriod must be true or false');
valid_title_sizes = {'Huge', 'huge', 'LARGE', 'Large', 'large', 'normalsize', ...
'small', 'footnotesize', 'scriptsize', 'tiny'};
assert(any(strcmp(o.titleSize, valid_title_sizes)), ...
['@table.table: titleSize must be one of ' strjoin(valid_title_sizes, ' ')]);
['@report_table.report_table: titleSize must be one of ' strjoin(valid_title_sizes, ' ')]);
% using o.seriesToUse, create series objects and put them in o.seriesElements
if ~isempty(o.data)
@ -113,6 +113,6 @@ end
o = rmfield(o, 'seriesToUse');
o = rmfield(o, 'data');
% Create table object
o = class(o, 'table');
% Create report_table object
o = class(o, 'report_table');
end

View File

@ -34,9 +34,9 @@ switch S.type
case fieldnames(A)
B.(S.subs) = V;
otherwise
error(['@table.subsasgn: field ' S.subs 'does not exist in the table class'])
error(['@report_table.subsasgn: field ' S.subs 'does not exist in the report_table class'])
end
otherwise
error('@table.subsasgn: syntax error')
error('@report_table.subsasgn: syntax error')
end
end

View File

@ -31,12 +31,12 @@ switch S(1).type
A = feval(S(1).subs, A);
end
otherwise
error(['@table.subsref: unknown field or method: ' S(1).subs]);
error(['@report_table.subsref: unknown field or method: ' S(1).subs]);
end
case {'()', '{}'}
error(['@table.subsref: ' S(1).type ' indexing not supported.']);
error(['@report_table.subsref: ' S(1).type ' indexing not supported.']);
otherwise
error('@table.subsref: subsref.m impossible case')
error('@report_table.subsref: subsref.m impossible case')
end
S = shiftS(S);

View File

@ -1,13 +1,13 @@
function o = write(o, fid)
%function o = write(o, fid)
% Write a Table object
% Write a Report_Table object
%
% INPUTS
% o [table] table object
% o [report_table] report_table object
% fid [integer] file id
%
% OUTPUTS
% o [table] table object
% o [report_table] report_table object
%
% SPECIAL REQUIREMENTS
% none
@ -31,7 +31,7 @@ function o = write(o, fid)
assert(fid ~= -1);
if ~o.seriesElements.numSeriesElements()
warning('@table.write: no series to plot, returning');
warning('@report_table.write: no series to plot, returning');
return;
end
@ -49,7 +49,7 @@ else
end
ndates = dates.ndat;
fprintf(fid, '%% Table Object\n');
fprintf(fid, '%% Report_Table Object\n');
fprintf(fid, '\\setlength{\\tabcolsep}{4pt}\n');
fprintf(fid, '\\begin{tabular}{@{}l');
@ -105,7 +105,7 @@ switch dates.freq
for i=2:size(thdr, 1)
split = find(thdr{i-1, 2} == 4, 1, 'first');
if isempty(split)
error('@table.write: Shouldn''t arrive here');
error('@report_table.write: Shouldn''t arrive here');
else
thdr{i, 2} = thdr{i-1, 2}(split+1:end);
thdr{i-1, 2} = thdr{i-1, 2}(1:split);
@ -127,9 +127,9 @@ switch dates.freq
end
end
case 12
error('@table.write: weekly dates not yet implemented');
error('@report_table.write: weekly dates not yet implemented');
otherwise
error('@table.write: invalid dynSeries frequency');
error('@report_table.write: invalid dynSeries frequency');
end
for i=1:length(yrsForAvgs)
fprintf(fid, ' & %d', years(i));
@ -138,7 +138,7 @@ fprintf(fid, '\\\\[-2pt]%%\n');
fprintf(fid, '\\hline%%\n');
fprintf(fid, '%%\n');
% Write Table Data
% Write Report_Table Data
ne = o.seriesElements.numSeriesElements();
for i=1:ne
o.seriesElements(i).write(fid, dates, o.precision, yrsForAvgs);
@ -149,5 +149,5 @@ end
fprintf(fid, '\\bottomrule\n');
fprintf(fid, '\\end{tabular} \\par \\medskip\n\n');
fprintf(fid, '%% End Table Object\n');
fprintf(fid, '%% End Report_Table Object\n');
end

View File

@ -1,11 +1,11 @@
function o = addTable(o, varargin)
%function o = addTable(o, varargin)
% Add a table to the Cell Array of tables in the report
% Add a report_table to the Cell Array of report_tables in the report
%
% INPUTS
% 1 args => add empty table
% 2 args => add given table
% 3 args => add table at index
% 1 args => add empty report_table
% 2 args => add given report_table
% 3 args => add report_table at index
%
% OUTPUTS
% updated section object