Skip to content

Commit

Permalink
fixed min angle validation, absorption typo and controls tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhroom committed Sep 4, 2024
1 parent 1ea0fce commit 98465a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions API/controlsClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
end

function set.resampleMinAngle(obj,val)
validateNumber(val, 'resampleNPoints must be a number');
if (val < 0 || val > 1)
throw(exceptions.invalidValue('resampleMinAngle must be between 0 and 1'));
end
Expand Down
2 changes: 1 addition & 1 deletion examples/miscellaneous/absorption/absorptionDPPC50.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@

% Now make a controls block....
controls = controlsClass();
controls.resampleMinAngle = 150;
controls.resampleNPoints = 150;
controls.parallel = 'contrasts';

[problem,results] = RAT(problem,controls);
Expand Down
27 changes: 13 additions & 14 deletions tests/testControlsClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ function testResampleMinAngle(testCase)
% bad resampleMinAngle option
testCase.verifyError(@() setResampleMinAngle('ab'), exceptions.invalidType.errorID);
testCase.verifyError(@() setResampleMinAngle(-1), exceptions.invalidValue.errorID);
testCase.verifyError(@() setResampleMinAngle(0), exceptions.invalidValue.errorID);
testCase.verifyError(@() setResampleMinAngle(12.3), exceptions.invalidValue.errorID);
function setResampleMinAngle(value)
testCase.controls.resampleMinAngle = value;
Expand All @@ -78,9 +77,9 @@ function testResampleNPoints(testCase)
testcase.controls.resampleNPoints = 10;
testcase.verifyEqual(testcase.controls.resampleNPoints, 10, 'set.resampleNPoints method is not working')
% bad option
testCase.verifyError(@() setResampleMinAngle('ab'), exceptions.invalidType.errorID);
testCase.verifyError(@() setResampleMinAngle(-1), exceptions.invalidValue.errorID);
testCase.verifyError(@() setResampleMinAngle(0.5), exceptions.invalidValue.errorID);
testCase.verifyError(@() setResampleNPoints('ab'), exceptions.invalidType.errorID);
testCase.verifyError(@() setResampleNPoints(0.5), exceptions.invalidType.errorID);
testCase.verifyError(@() setResampleNPoints(-1), exceptions.invalidValue.errorID);
function setResampleNPoints(value)
testCase.controls.resampleNPoints = value;
end
Expand Down Expand Up @@ -407,7 +406,7 @@ function testSetProcedureWithDream(testCase)
'adaptPCR', true,...
'parallel', parallelOptions.Contrasts.value,...
'calcSldDuringFit', true,...
'resampleMinAngle', 0.1,...
'resampleMinAngle', 0,...
'resampleNPoints', 10,...
'display', displayOptions.Notify.value});
testCase.verifyEqual(testCase.controls.procedure, procedures.Dream.value, 'setProcedure method is not working');
Expand All @@ -419,7 +418,7 @@ function testSetProcedureWithDream(testCase)
testCase.verifyTrue(testCase.controls.adaptPCR, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Contrasts.value, 'setProcedure method is not working');
testCase.verifyTrue(testCase.controls.calcSldDuringFit, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.1, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleMinAngle, 0, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleNPoints, 10, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.display, displayOptions.Notify.value, 'setProcedure method is not working');

Expand Down Expand Up @@ -460,7 +459,7 @@ function testSetProcedureWithNS(testCase)
'nsTolerance', 0.5,...
'parallel', parallelOptions.Contrasts.value,...
'calcSldDuringFit', true,...
'resampleMinAngle', 0.1,...
'resampleMinAngle', 0,...
'resampleNPoints', 10,...
'display', displayOptions.Notify.value});
testCase.verifyEqual(testCase.controls.procedure, procedures.NS.value, 'setProcedure method is not working');
Expand All @@ -470,7 +469,7 @@ function testSetProcedureWithNS(testCase)
testCase.verifyEqual(testCase.controls.nsTolerance, 0.5, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Contrasts.value, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.calcSldDuringFit, true, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.1, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleMinAngle, 0, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleNPoints, 10, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.display, displayOptions.Notify.value, 'setProcedure method is not working');

Expand Down Expand Up @@ -513,7 +512,7 @@ function testSetProcedureWithDE(testCase)
'numGenerations', 3,...
'parallel', parallelOptions.Contrasts.value,...
'calcSldDuringFit', true,...
'resampleMinAngle', 0.1,...
'resampleMinAngle', 0,...
'resampleNPoints', 10,...
'display', displayOptions.Notify.value,...
'updateFreq', 1,...
Expand All @@ -527,7 +526,7 @@ function testSetProcedureWithDE(testCase)
testCase.verifyEqual(testCase.controls.numGenerations, 3, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Contrasts.value, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.calcSldDuringFit, true, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.1, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleMinAngle, 0, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleNPoints, 10, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.display, displayOptions.Notify.value, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.updateFreq, 1, 'setProcedure method is not working');
Expand Down Expand Up @@ -570,7 +569,7 @@ function testSetProcedureWithSimplex(testCase)
'updatePlotFreq', 4, ...
'parallel', parallelOptions.Contrasts.value,...
'calcSldDuringFit', true,...
'resampleMinAngle', 0.1,...
'resampleMinAngle', 0,...
'resampleNPoints', 10,...
'display', displayOptions.Notify.value});
testCase.verifyEqual(testCase.controls.procedure, procedures.Simplex.value, 'setProcedure method is not working');
Expand All @@ -582,7 +581,7 @@ function testSetProcedureWithSimplex(testCase)
testCase.verifyEqual(testCase.controls.updatePlotFreq, 4, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Contrasts.value, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.calcSldDuringFit, true, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.1, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleMinAngle, 0, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleNPoints, 10, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.display, displayOptions.Notify.value, 'setProcedure method is not working');

Expand Down Expand Up @@ -611,13 +610,13 @@ function testSetProcedureWithCalculate(testCase)
testCase.controls = testCase.controls.setProcedure(procedures.Calculate.value,...
{'parallel', parallelOptions.Contrasts.value,...
'calcSldDuringFit', true,...
'resampleMinAngle', 0.1,...
'resampleMinAngle', 0,...
'resampleNPoints', 10,...
'display', displayOptions.Notify.value});
testCase.verifyEqual(testCase.controls.procedure, procedures.Calculate.value, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.parallel, parallelOptions.Contrasts.value, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.calcSldDuringFit, true, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleMinAngle, 0.1, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleMinAngle, 0, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.resampleNPoints, 10, 'setProcedure method is not working');
testCase.verifyEqual(testCase.controls.display, displayOptions.Notify.value, 'setProcedure method is not working');

Expand Down

0 comments on commit 98465a3

Please sign in to comment.