diff --git a/arFramework3/Examples/ToyModels/PEtab_Tests/TestFeature.m b/arFramework3/Examples/ToyModels/PEtab_Tests/TestFeature.m index 5141d9f0..47704ff9 100644 --- a/arFramework3/Examples/ToyModels/PEtab_Tests/TestFeature.m +++ b/arFramework3/Examples/ToyModels/PEtab_Tests/TestFeature.m @@ -11,27 +11,27 @@ cases = cases'; Ncases = numel(cases); -try - parpool(4) -end +% try +% parpool(4) +% end -for i = 1:Ncases +for iTest = 1:Ncases - cd(cases{i}) - fprintf( 2, ['\n\nCase ' cases{i} '...\n'] ); + cd(cases{iTest}) + fprintf( 2, ['\n\nCase ' cases{iTest} '...\n'] ); try arInit % arImportPEtab({'_model','_observables','_measurements','_conditions','_parameters'}) % tests default behavior - arImportPEtab(['_' cases{i}]) % tests yaml file read + arImportPEtab(['_' cases{iTest}]) % tests yaml file read ar.config.useFitErrorCorrection = 0; arSimu(true,true,true) arCalcMerit [~,scores] = arGetMerit; - chi2(i) = scores.chi2_res; - llh(i) = scores.loglik/(-2); + chi2(iTest) = scores.chi2_res; + llh(iTest) = scores.loglik/(-2); % check simulations simus = tdfread('_simulations.tsv'); @@ -41,7 +41,7 @@ simus2.simulation = NaN(size(simus2.simulation)); q = 1; - if strcmp(cases{i},'0006') + if strcmp(cases{iTest},'0006') simus2.simulation(1) = ar.model.data(1).yExpSimu; simus2.simulation(2) = ar.model.data(2).yExpSimu; else @@ -70,32 +70,32 @@ end abs(simus.simulation - simus2.simulation); - SimuDiff(i) = sum(abs(simus.simulation - simus2.simulation)); - SolTable = ReadOutSolutionFile(cases{i}); + SimuDiff(iTest) = sum(abs(simus.simulation - simus2.simulation)); + SolTable = ReadOutSolutionFile(cases{iTest}); - chi2Solution(i) = str2num(SolTable.Value{strcmp(SolTable.Variable,'chi2:')}); - llhSolution(i) = str2num(SolTable.Value{strcmp(SolTable.Variable,'llh:')}); + chi2Solution(iTest) = str2num(SolTable.Value{strcmp(SolTable.Variable,'chi2:')}); + llhSolution(iTest) = str2num(SolTable.Value{strcmp(SolTable.Variable,'llh:')}); - TolChi2(i) = str2num(SolTable.Value{strcmp(SolTable.Variable,'tol_chi2:')}); - TolLLH(i) = str2num(SolTable.Value{strcmp(SolTable.Variable,'tol_llh:')}); - TolSimu(i) = str2num(SolTable.Value{strcmp(SolTable.Variable,'tol_simulations:')}); - Error{i} = 'none'; - ErrorFile{i} = 'none'; - ErrorLine{i} = 'none'; + TolChi2(iTest) = str2num(SolTable.Value{strcmp(SolTable.Variable,'tol_chi2:')}); + TolLLH(iTest) = str2num(SolTable.Value{strcmp(SolTable.Variable,'tol_llh:')}); + TolSimu(iTest) = str2num(SolTable.Value{strcmp(SolTable.Variable,'tol_simulations:')}); + Error{iTest} = 'none'; + ErrorFile{iTest} = 'none'; + ErrorLine{iTest} = 'none'; catch Err - Error{i} = Err.message; - ErrorFile{i} = Err.stack.file; - ErrorLine{i} = Err.stack.line; - chi2(i) = nan; - llh(i) = nan; - SimuDiff(i) = nan; + Error{iTest} = Err.message; + ErrorFile{iTest} = Err.stack.file; + ErrorLine{iTest} = Err.stack.line; + chi2(iTest) = nan; + llh(iTest) = nan; + SimuDiff(iTest) = nan; - chi2Solution(i) = nan; - llhSolution(i) = nan; + chi2Solution(iTest) = nan; + llhSolution(iTest) = nan; - TolChi2(i) = nan; - TolLLH(i) = nan; - TolSimu(i) = nan; + TolChi2(iTest) = nan; + TolLLH(iTest) = nan; + TolSimu(iTest) = nan; end cd .. @@ -119,10 +119,6 @@ Working = double(SimuCheck.*Chi2Check.*LLHCheck); -if ~silent - Table = table(cases,Working,SimuCheck,Chi2Check,LLHCheck,SimuDiff,Chi2Diff,LLHDiff,chi2,llh,Error,ErrorFile,ErrorLine) -end - if sum(Working) == numel(Working) fprintf( 2, 'PASSED\n' ); else @@ -130,6 +126,10 @@ error( 'FAILED'); end +if ~silent + Table = table(cases,Working,SimuCheck,Chi2Check,LLHCheck,SimuDiff,Chi2Diff,LLHDiff,chi2,llh,Error,ErrorFile,ErrorLine) +end + function solution = ReadOutSolutionFile(caseName) %% Setup the Import Options and import the data diff --git a/arFramework3/ImportExport/arLoadDataPEtab.m b/arFramework3/ImportExport/arLoadDataPEtab.m index 5e3866e4..484e9e9b 100644 --- a/arFramework3/ImportExport/arLoadDataPEtab.m +++ b/arFramework3/ImportExport/arLoadDataPEtab.m @@ -74,8 +74,8 @@ if length(ar.model.xNames{k}) == 1 for i = 1:length(fn_rep) for j = 1:size(Tobs.(fn_rep{i}),1) - Tobs.(fn_rep{i})(j) = arSubs(str2sym(string(Tobs.(fn_rep{i})(j))), ... - arSym(ar.model.xNames{k}), arSym(ar.model.x{k})); + Tobs.(fn_rep{i})(j) = string(arSubs(str2sym(string(Tobs.(fn_rep{i})(j))), ... + arSym(ar.model.xNames{k}), arSym(ar.model.x{k}))); end end end