From f47555a92f819e4d12b6efa6ff0b924b303b9e82 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Thu, 2 Jan 2014 09:35:45 +0100 Subject: [PATCH] reporting: make vlineAfter accept a cell array of dates --- matlab/reporting/@report_table/report_table.m | 8 +++- matlab/reporting/@report_table/write.m | 8 ++-- matlab/reporting/allCellsAreDates.m | 39 +++++++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 matlab/reporting/allCellsAreDates.m diff --git a/matlab/reporting/@report_table/report_table.m b/matlab/reporting/@report_table/report_table.m index e84803dce..6d68f0253 100644 --- a/matlab/reporting/@report_table/report_table.m +++ b/matlab/reporting/@report_table/report_table.m @@ -12,7 +12,7 @@ function o = report_table(varargin) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2013 Dynare Team +% Copyright (C) 2013-2014 Dynare Team % % This file is part of Dynare. % @@ -71,6 +71,10 @@ elseif nargin > 1 end end +if isa(o.vlineAfter, 'dates') + o.vlineAfter = {o.vlineAfter}; +end + % Check options provided by user assert(ischar(o.title), '@report_table.report_table: title must be a string'); assert(islogical(o.showHlines), '@report_table.report_table: showHlines must be true or false'); @@ -83,7 +87,7 @@ assert(isempty(o.data) || isa(o.data, 'dseries'), ... '@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) || isa(o.vlineAfter, 'dates'), ... +assert(isempty(o.vlineAfter) || allCellsAreDates(o.vlineAfter), ... '@report_table.report_table: vlineAfter must be a dates'); if o.showVlines o.vlineAfter = ''; diff --git a/matlab/reporting/@report_table/write.m b/matlab/reporting/@report_table/write.m index 0325a7455..2e00b0c46 100644 --- a/matlab/reporting/@report_table/write.m +++ b/matlab/reporting/@report_table/write.m @@ -64,9 +64,11 @@ for i=1:ndates end end if ~isempty(o.vlineAfter) - if dates(i) == o.vlineAfter - if ~(o.vlineAfterEndOfPeriod && dates(i).time(2) == dates(i).freq) - fprintf(fid, '|'); + for j=1:length(o.vlineAfter) + if dates(i) == o.vlineAfter{j} + if ~(o.vlineAfterEndOfPeriod && dates(i).time(2) == dates(i).freq) + fprintf(fid, '|'); + end end end end diff --git a/matlab/reporting/allCellsAreDates.m b/matlab/reporting/allCellsAreDates.m new file mode 100644 index 000000000..533ff49e4 --- /dev/null +++ b/matlab/reporting/allCellsAreDates.m @@ -0,0 +1,39 @@ +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 . + +assert(iscell(dcell)); +tf = true; +for i=1:length(dcell) + if ~isa(dcell{i}, 'dates') + tf = false; + return; + end +end +end \ No newline at end of file