Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
TommasoBelluzzo authored Oct 25, 2020
1 parent 5c3f5c1 commit acf3025
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 454 deletions.
Binary file modified Datasets/Example_Large.mat
Binary file not shown.
Binary file modified Datasets/Example_Small_1.mat
Binary file not shown.
Binary file modified Datasets/Example_Small_2.mat
Binary file not shown.
Binary file modified Datasets/Example_Small_2.xlsx
Binary file not shown.
684 changes: 241 additions & 443 deletions ScriptsDataset/parse_dataset.m

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions ScriptsDataset/validate_dataset.m
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
% [INPUT]
% ds = A structure representing the dataset.
% validation_type = A string representing the type of validation to perform (optional, default='').
% type = A string representing the type of validation to perform (optional, default='').

function ds = validate_dataset(varargin)

persistent validation_types;
persistent types;

if (isempty(validation_types))
validation_types = {
if (isempty(types))
types = {
'component' 'connectedness' 'cross-entropy' 'cross-quantilogram' ...
'cross-sectional' 'default' 'liquidity' 'regime-switching' 'spillover'
};
Expand All @@ -18,22 +18,22 @@
if (isempty(ip))
ip = inputParser();
ip.addRequired('ds',@(x)validateattributes(x,{'struct'},{'nonempty'}));
ip.addOptional('validation_type','',@(x)any(validatestring(x,validation_types)));
ip.addOptional('type','',@(x)any(validatestring(x,types)));
end

ip.parse(varargin{:});

ipr = ip.Results;
ds = ipr.ds;
validation_type = ipr.validation_type;
type = ipr.type;

nargoutchk(1,1);

ds = validate_dataset_internal(ds,validation_type);
ds = validate_dataset_internal(ds,type);

end

function ds = validate_dataset_internal(ds,validation_type)
function ds = validate_dataset_internal(ds,type)

validate_field(ds,'TimeSeries',{'cellstr'},{'nonempty' 'size' [1 8]});

Expand Down Expand Up @@ -119,8 +119,8 @@
validate_field(ds,'SupportsSpillover',{'logical'},{'scalar'});
validate_field(ds,'SupportsComparison',{'logical'},{'scalar'});

if (~isempty(validation_type))
measures = [upper(validation_type(1)) validation_type(2:end)];
if (~isempty(type))
measures = [upper(type(1)) type(2:end)];
measures_underscore = strfind(measures,'-');

if (~isempty(measures_underscore))
Expand All @@ -131,7 +131,7 @@
supports = ['Supports' measures];

if (~ds.(supports))
error(['The dataset cannot be used for calculating ''' validation_type ''' measures.']);
error(['The dataset cannot be used for calculating ''' type ''' measures.']);
end
end

Expand Down
78 changes: 78 additions & 0 deletions ScriptsDataset/validate_xls.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
% [INPUT]
% file = A string representing the full path to the Excel spreadsheet.
% type = A string representing the type of Excel spreadsheet:
% - 'D' for dataset.
% - 'T' for template.

function file_sheets = validate_xls(varargin)

persistent ip;

if (isempty(ip))
ip = inputParser();
ip.addRequired('file',@(x)validateattributes(x,{'char'},{'nonempty' 'size' [1 NaN]}));
ip.addRequired('type',@(x)any(validatestring(x,{'D' 'T'})));
end

ip.parse(varargin{:});

ipr = ip.Results;
file = ipr.file;
type = ipr.type;

nargoutchk(1,1);

file_sheets = validate_xls_internal(file,type);

end

function file_sheets = validate_xls_internal(file,type)

if (strcmp(type,'D'))
label = 'dataset';
else
label = 'template';
end

if (exist(file,'file') == 0)
error(['The ' label ' file ''' file ''' could not be found.']);
end

[~,~,extension] = fileparts(file);

if (~strcmp(extension,'.xlsx'))
error(['The ' label ' file ''' file ''' is not a valid Excel spreadsheet.']);
end

if (verLessThan('MATLAB','9.7'))
if (ispc())
check_format = true;

try
[file_status,file_sheets,file_format] = xlsfinfo(file);
catch
[file_status,file_sheets] = xlsfinfo(file);
file_format = [];

check_format = false;
end

if (isempty(file_status) || (check_format && ~strcmp(file_format,'xlOpenXMLWorkbook')))
error(['The ' label ' file ''' file ''' is not a valid Excel spreadsheet.']);
end
else
[file_status,file_sheets] = xlsfinfo(file);

if (isempty(file_status))
error(['The ' label ' file ''' file ''' is not a valid Excel spreadsheet.']);
end
end
else
try
file_sheets = sheetnames(file);
catch
error(['The ' label ' file ''' file ''' is not a valid Excel spreadsheet.']);
end
end

end
Binary file modified Templates/TemplateComparison.xlsx
Binary file not shown.
Binary file modified Templates/TemplateCrossSectional.xlsx
Binary file not shown.

0 comments on commit acf3025

Please sign in to comment.