From 3ba1dcd408fc4b7be95e865f78a3357894ff17a7 Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Wed, 20 Mar 2013 13:04:46 +0100 Subject: [PATCH] reporting: @table, @graph: require data to be dynSeries, simplify checks --- matlab/reporting/@graph/createGraph.m | 4 ---- matlab/reporting/@graph/graph.m | 24 ++++-------------------- matlab/reporting/@table/table.m | 24 ++++-------------------- 3 files changed, 8 insertions(+), 44 deletions(-) diff --git a/matlab/reporting/@graph/createGraph.m b/matlab/reporting/@graph/createGraph.m index 3d11eb9c8e..98035a73a2 100644 --- a/matlab/reporting/@graph/createGraph.m +++ b/matlab/reporting/@graph/createGraph.m @@ -49,10 +49,6 @@ end %set(h, 'PaperPositionMode', 'auto'); %set(h, 'units', 'normalized', 'outerposition', [0 0 1 1]); -if length(o.data) > 1 - o.data = [o.data{:}]; -end - if isempty(o.seriestouse) ds = o.data; else diff --git a/matlab/reporting/@graph/graph.m b/matlab/reporting/@graph/graph.m index 67585396e7..56fd9518e9 100644 --- a/matlab/reporting/@graph/graph.m +++ b/matlab/reporting/@graph/graph.m @@ -112,26 +112,10 @@ 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), '@graph.graph: must provide data'); -msg = ['@graph.graph: data must either be a dynSeries or a cell array of ' ... - 'dynSeries']; -if length(o.data) == 1 - assert(isa(o.data, 'dynSeries'), msg); -else - assert(iscell(o.data), msg); - for i=1:length(o.data) - assert(isa(o.data{i}, 'dynSeries'), msg); - end -end - -msg = ['@graph.graph: series to use must be a cell array of string(s)']; -if ~isempty(o.seriestouse) - assert(iscell(o.seriestouse), msg); - for i=1:length(o.seriestouse) - assert(ischar(o.seriestouse{i}), msg); - end -end +assert(~isempty(o.data) && isa(o.data, 'dynSeries'), ['@graph.graph: must ' ... + 'provide data as a dynSeries']); +assert(isempty(o.seriestouse) || iscellstr(o.seriestouse), ['@graph.graph: ' ... + 'series to use must be a cell array of string(s)']); % Create graph object o = class(o, 'graph'); diff --git a/matlab/reporting/@table/table.m b/matlab/reporting/@table/table.m index 8be9320559..0eb76538ae 100644 --- a/matlab/reporting/@table/table.m +++ b/matlab/reporting/@table/table.m @@ -78,26 +78,10 @@ assert(isint(o.precision), '@table.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. ' ... '''dynDates(''1999q1''):dynDates(''1999q3'')''.']); - -assert(~isempty(o.data), '@table.table: must provide data'); -msg = ['@table.table: data must either be a dynSeries or a cell array of ' ... - 'dynSeries']; -if length(o.data) == 1 - assert(isa(o.data, 'dynSeries'), msg); -else - assert(iscell(o.data), msg); - for i=1:length(o.data) - assert(isa(o.data{i}, 'dynSeries'), msg); - end -end - -msg = ['@table.table: series to use must be a cell array of string(s)']; -if ~isempty(o.seriestouse) - assert(iscell(o.seriestouse), msg); - for i=1:length(o.seriestouse) - assert(ischar(o.seriestouse{i}), msg); - end -end +assert(~isempty(o.data) && isa(o.data, 'dynSeries'), ['@table.table: must ' ... + 'provide data as a dynSeries']); +assert(isempty(o.seriestouse) || iscellstr(o.seriestouse), ['@table.table: ' ... + 'series to use must be a cell array of string(s)']); % Create table object o = class(o, 'table'); -- GitLab