Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
81f7f8a4
Commit
81f7f8a4
authored
Mar 14, 2013
by
Houtan Bastani
Browse files
reporting: check user input for table class
parent
12b2b96a
Changes
2
Hide whitespace changes
Inline
Side-by-side
matlab/reports/@table/table.m
View file @
81f7f8a4
...
...
@@ -39,9 +39,8 @@ o.hlines = false;
o
.
vlines
=
false
;
o
.
data
=
''
;
o
.
datatitles
=
''
;
o
.
seriestouse
=
'all'
;
o
.
range
=
''
;
o
.
seriestouse
=
''
;
o
.
range
=
{};
o
.
precision
=
1
;
if
nargin
==
1
...
...
@@ -69,6 +68,42 @@ elseif nargin > 1
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
o
=
class
(
o
,
'table'
);
end
\ No newline at end of file
matlab/reports/@table/write.m
View file @
81f7f8a4
...
...
@@ -34,7 +34,7 @@ if isempty(o.data)
return
end
if
strcmpi
(
o
.
seriestouse
,
'all'
)
if
isempty
(
o
.
seriestouse
)
ds
=
o
.
data
;
else
ds
=
o
.
data
{
o
.
seriestouse
{:}};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment