Skip to content

Commit

Permalink
Merge branch 'develop’:
Browse files Browse the repository at this point in the history
- Added message IDs to warnings and errors.
  • Loading branch information
Christopher Hummersone committed Mar 29, 2017
2 parents a850b06 + 8606484 commit 7b8d0ee
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
44 changes: 23 additions & 21 deletions MASSEF.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,31 +148,31 @@
% validate properties

function set.blocksize(obj,val)
assert(isnumeric(val) && isscalar(val),'blocksize must be a numeric scalar.')
assert(round(val)==val,'blocksize must be an integer.')
assert(val>=1,'blocksize must be greater than or equal to 1.')
assert(isnumeric(val) && isscalar(val),'MASSEF:blocksize:invalid','blocksize must be a numeric scalar.')
assert(round(val)==val,'MASSEF:invalidBlocksize','blocksize must be an integer.')
assert(val>=1,'MASSEF:invalidBlocksize','blocksize must be greater than or equal to 1.')
obj.blocksize = val;
end

function set.evalPEASS(obj,val)
assert(islogical(val) && isscalar(val),'evalPEASS must be a logical scalar.')
assert(islogical(val) && isscalar(val),'MASSEF:evalPEASS:invalid','evalPEASS must be a logical scalar.')
obj.evalPEASS = val;
end

function set.evalSTOI(obj,val)
assert(islogical(val) && isscalar(val),'evalSTOI must be a logical scalar.')
assert(islogical(val) && isscalar(val),'MASSEF:evalSTOI:invalid','evalSTOI must be a logical scalar.')
obj.evalSTOI = val;
end

function set.parpool(obj,val)
if ~isempty(val)
assert(isa(val,'parallel.Pool'),'parpool must be a parallel.pool object.')
assert(isa(val,'parallel.Pool'),'MASSEF:parpool:invalid','parpool must be a parallel.pool object.')
end
obj.parpool = val;
end

function set.results_filename(obj,val)
assert(ischar(val),'results_filename must be a char array')
assert(ischar(val),'MASSEF:results_filename:invalid','results_filename must be a char array')
obj.results_filename = val;
end

Expand Down Expand Up @@ -243,7 +243,7 @@ function execute(obj,mixtures,separators)
% object, is saved to the file given by MASSEF.results_filename.

% check the mixtures
assert(isa(mixtures,'iosr.bss.mixture'),'The MIXTURES input must contain one or more objects of class ''iosr.bss.mixture''.')
assert(isa(mixtures,'iosr.bss.mixture'),'MASSEF:execute:invalidMixtures','The MIXTURES input must contain one or more objects of class ''iosr.bss.mixture''.')

if exist('separators','var')~=1
separators = {};
Expand All @@ -270,7 +270,7 @@ function execute(obj,mixtures,separators)
if exist(tempdir,'dir')~=7
success = mkdir(tempdir);
if ~success
error('Unable to create directory %s. Please create it.',tempdir)
error('MASSEF:execute:mkdir','Unable to create directory %s. Please create it.',tempdir)
end
end

Expand Down Expand Up @@ -455,22 +455,22 @@ function evaluate(obj,originalFiles,estimateFile,tag,mixnum,sepnum,estnum)
if exist('tag','var')~=1
tag = '';
else
assert(ischar(tag),'TAG must be a char array')
assert(ischar(tag),'MASSEF:evaluate:invalidTag','TAG must be a char array')
end
if exist('mixnum','var')~=1
mixnum = 1;
else
assert(isscalar(mixnum),'MIXNUM must be a scalar')
assert(isscalar(mixnum),'MASSEF:evaluate:invalidMixnum','MIXNUM must be a scalar')
end
if exist('sepnum','var')~=1
sepnum = 1;
else
assert(isscalar(sepnum),'SEPNUM must be a scalar')
assert(isscalar(sepnum),'MASSEF:evaluate:invalidSepnum','SEPNUM must be a scalar')
end
if exist('estnum','var')~=1
estnum = 1;
else
assert(isscalar(estnum),'ESTNUM must be a scalar')
assert(isscalar(estnum),'MASSEF:evaluate:invalidEstnum','ESTNUM must be a scalar')
end

[estimate,fs] = audioread(estimateFile);
Expand Down Expand Up @@ -659,6 +659,8 @@ function save(obj)
display('Found existing IoSR Matlab Toolbox directory')
end
end

iosr.install;

%% Remaining clean up

Expand Down Expand Up @@ -874,7 +876,7 @@ function evaluatePEASS(obj,estimateFile,originalfiles, ...

% check format
if numel(options)>1
error('The input to MASSEF should be a 1x1 structure. Cell-array fields should be encapsulated within a single cell.')
error('MASSEF:validate_options:invalidInput','The input to MASSEF should be a 1x1 structure. Cell-array fields should be encapsulated within a single cell.')
end

fields_in = fieldnames(options);
Expand All @@ -896,7 +898,7 @@ function evaluatePEASS(obj,estimateFile,originalfiles, ...

% check for invalid options
for r = 1:length(fields_in)
assert(any(strcmpi(fields_in{r},def_fields)),['Invalid option ''' fields_in{r} ''' specified.'])
assert(any(strcmpi(fields_in{r},def_fields)),'MASSEF:validate_options:invalidOption',['Invalid option ''' fields_in{r} ''' specified.'])
end

% write defaults
Expand All @@ -916,7 +918,7 @@ function evaluatePEASS(obj,estimateFile,originalfiles, ...
IV_space = [numMixtures max(1,numSeparators)];

iterations = prod(IV_space); % total number of results
assert(numMixtures>0,'No mixtures have been specified')
assert(numMixtures>0,'MASSEF:initialise_IVs:noMixtures','No mixtures have been specified')
%assert(numSeparators>0,'No separators have been specified')

IVs = struct('algo_num',[],'mixture_num',[]);
Expand All @@ -932,11 +934,11 @@ function evaluatePEASS(obj,estimateFile,originalfiles, ...
function check_separator(obj)
%CHECK_SEPARATOR Check separator meets requirements

assert(isprop(obj,'label'),['The object of class ''' class(obj) ''' does not have the required property ''label'''])
assert(ischar(obj.label),['The ''label'' property of the ''' class(obj) ''' object should return a char array'])
assert(isprop(obj,'estTag'),['The object of class ''' class(obj) ''' does not have the required property ''estTag'''])
assert(iscellstr(obj.estTag),['The ''estTag'' property of the ''' class(obj) ''' object should return a cell array of strings'])
assert(ismethod(obj,'separate'),['The object of class ''' class(obj) ''' does not have the required method ''separate'''])
assert(isprop(obj,'label'),'MASSEF:check_separator:invalidSepNoLabel',['The object of class ''' class(obj) ''' does not have the required property ''label'''])
assert(ischar(obj.label),'MASSEF:check_separator:invalidSepLabelProp',['The ''label'' property of the ''' class(obj) ''' object should return a char array'])
assert(isprop(obj,'estTag'),'MASSEF:check_separator:invalidSepNoEstTag',['The object of class ''' class(obj) ''' does not have the required property ''estTag'''])
assert(iscellstr(obj.estTag),'MASSEF:check_separator:invalidSepEstTagProp',['The ''estTag'' property of the ''' class(obj) ''' object should return a cell array of strings'])
assert(ismethod(obj,'separate'),'MASSEF:check_separator:invalidSepNoSepMethod',['The object of class ''' class(obj) ''' does not have the required method ''separate'''])

end

Expand Down
8 changes: 4 additions & 4 deletions MASSEFresults.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function removeDuplicates(obj)
% parameter should be a function handle that takes the
% value as its input, and returns a logical value.

assert(mod(length(varargin),2)==0,'input must contain parameter/value pairs')
assert(mod(length(varargin),2)==0,'MASSEFresults:filter:invalidArgs','input must contain parameter/value pairs')
data = obj.data;

% work through varargin
Expand Down Expand Up @@ -327,7 +327,7 @@ function debug(obj) %#ok<MANU>
case 'mean'
fhandle = @mean;
otherwise
error('Unknown filter parameter ''%s''.',filterval)
error('MASSEFresults:filterRowOrAggregate:unknownOption','Unknown filter parameter ''%s''.',filterval)
end
% do stats
try
Expand Down Expand Up @@ -366,7 +366,7 @@ function debug(obj) %#ok<MANU>
function dataTable = addData(dataTable,key,keyVal,varargin)
%ADDDATA add data to lookup tables.

assert(mod(length(varargin),2)==0,'input must contain parameter/value pairs')
assert(mod(length(varargin),2)==0,'MASSEFresults:addData:invalidArgs','input must contain parameter/value pairs')
rI = find(ismember(dataTable.(key),keyVal),1,'first');
if isempty(rI) % add a new row
% get data from varargin
Expand Down Expand Up @@ -412,7 +412,7 @@ function debug(obj) %#ok<MANU>
function dataTable = filterRows(dataTable,fhandle,col)
%FILTERROWS filter the rows in a table.

assert(isa(fhandle,'function_handle'),'Parameter must be a function handle')
assert(isa(fhandle,'function_handle'),'MASSEFresults:filterRows:invalidFhandle','Parameter must be a function handle')
dataTable = dataTable(fhandle(dataTable.(col)),:);

end
Expand Down
4 changes: 2 additions & 2 deletions MASSEFseparator.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
elseif iscellstr(val)
obj.estTag = val;
else
error('''estTag'' must be a char array or cell array of strings');
error('MASSEFseparator:estTag:invalid','''estTag'' must be a char array or cell array of strings');
end
end

Expand All @@ -47,7 +47,7 @@
if ischar(val)
obj.label = val;
else
error('''label'' must be a char array');
error('MASSEFseparator:label:invalid','''label'' must be a char array');
end
end

Expand Down

0 comments on commit 7b8d0ee

Please sign in to comment.