Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dynare
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
dynare
Commits
fb8cf54f
Commit
fb8cf54f
authored
Mar 14, 2013
by
Houtan Bastani
Browse files
Options
Downloads
Patches
Plain Diff
reporting: check user input for table class
parent
33b76367
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
matlab/reporting/@table/table.m
+38
-3
38 additions, 3 deletions
matlab/reporting/@table/table.m
matlab/reporting/@table/write.m
+1
-1
1 addition, 1 deletion
matlab/reporting/@table/write.m
with
39 additions
and
4 deletions
matlab/reporting/@table/table.m
+
38
−
3
View file @
fb8cf54f
...
@@ -39,9 +39,8 @@ o.hlines = false;
...
@@ -39,9 +39,8 @@ o.hlines = false;
o
.
vlines
=
false
;
o
.
vlines
=
false
;
o
.
data
=
''
;
o
.
data
=
''
;
o
.
datatitles
=
''
;
o
.
seriestouse
=
''
;
o
.
seriestouse
=
'all'
;
o
.
range
=
{};
o
.
range
=
''
;
o
.
precision
=
1
;
o
.
precision
=
1
;
if
nargin
==
1
if
nargin
==
1
...
@@ -69,6 +68,42 @@ elseif nargin > 1
...
@@ -69,6 +68,42 @@ elseif nargin > 1
end
end
end
end
% Check options provided by user
assert
(
ischar
(
o
.
title
),
'@table.table: title must be a string'
);
assert
(
ischar
(
o
.
footnote
),
'@table.table: footnote must be a string'
);
assert
(
ischar
(
o
.
config
),
'@table.table: config file must be a string'
);
assert
(
islogical
(
o
.
hlines
),
'@table.table: hlines must be true or false'
);
assert
(
islogical
(
o
.
vlines
),
'@table.table: vlines must be true or false'
);
assert
(
isint
(
o
.
precision
),
'@table.table: precision must be an int'
);
assert
(
isempty
(
o
.
range
)
||
(
iscell
(
o
.
range
)
&&
length
(
o
.
range
)
==
2
&&
...
ischar
(
o
.
range
{
1
})
&&
ischar
(
o
.
range
{
2
})),
...
[
'@table.table: range is specified as
''
{
''
1999q1
''
,
''
999q2
''
}
''
.'
]);
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 either be a string or a cell array '
...
'of strings'
];
if
~
isempty
(
o
.
seriestouse
)
if
length
(
o
.
seriestouse
)
==
1
assert
(
ischar
(
o
.
seriestouse
),
msg
);
else
assert
(
iscell
(
o
.
seriestouse
),
msg
);
for
i
=
1
:
length
(
o
.
seriestouse
)
assert
(
ischar
(
o
.
seriestouse
{
i
}),
msg
);
end
end
end
% Create table object
% Create table object
o
=
class
(
o
,
'table'
);
o
=
class
(
o
,
'table'
);
end
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
matlab/reporting/@table/write.m
+
1
−
1
View file @
fb8cf54f
...
@@ -34,7 +34,7 @@ if isempty(o.data)
...
@@ -34,7 +34,7 @@ if isempty(o.data)
return
return
end
end
if
strcmpi
(
o
.
seriestouse
,
'all'
)
if
isempty
(
o
.
seriestouse
)
ds
=
o
.
data
;
ds
=
o
.
data
;
else
else
ds
=
o
.
data
{
o
.
seriestouse
{:}};
ds
=
o
.
data
{
o
.
seriestouse
{:}};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment