From 86064842af4eebc1aee4bd8fc15be26c8379b554 Mon Sep 17 00:00:00 2001 From: Christopher Hummersone Date: Wed, 29 Mar 2017 09:30:14 +0100 Subject: [PATCH] Added message IDs to warnings and errors. --- MASSEF.m | 44 +++++++++++++++++++++++--------------------- MASSEFresults.m | 8 ++++---- MASSEFseparator.m | 4 ++-- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/MASSEF.m b/MASSEF.m index 79e09a2..0788ad0 100644 --- a/MASSEF.m +++ b/MASSEF.m @@ -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 @@ -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 = {}; @@ -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 @@ -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); @@ -659,6 +659,8 @@ function save(obj) display('Found existing IoSR Matlab Toolbox directory') end end + + iosr.install; %% Remaining clean 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); @@ -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 @@ -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',[]); @@ -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 diff --git a/MASSEFresults.m b/MASSEFresults.m index 154c56d..a11e6a9 100644 --- a/MASSEFresults.m +++ b/MASSEFresults.m @@ -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 @@ -327,7 +327,7 @@ function debug(obj) %#ok case 'mean' fhandle = @mean; otherwise - error('Unknown filter parameter ''%s''.',filterval) + error('MASSEFresults:filterRowOrAggregate:unknownOption','Unknown filter parameter ''%s''.',filterval) end % do stats try @@ -366,7 +366,7 @@ function debug(obj) %#ok 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 @@ -412,7 +412,7 @@ function debug(obj) %#ok 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 diff --git a/MASSEFseparator.m b/MASSEFseparator.m index 8a9efba..20c5360 100644 --- a/MASSEFseparator.m +++ b/MASSEFseparator.m @@ -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 @@ -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