Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/runTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
build_and_test_mex:
strategy:
matrix:
platform: [windows-latest, ubuntu-22.04, macos-15-intel, macos-latest]
platform: [windows-2022, ubuntu-22.04, macos-15-intel, macos-latest]
runs-on: ${{ matrix.platform }}
needs: [build_cpp]

Expand Down
36 changes: 36 additions & 0 deletions API/checkRange.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function problemStruct = checkRange(problemStruct, limits)
% Check the range of fitted parameters, remove parameter from fit if range is too small.
%
% Parameters
% ----------
% problemStruct : struct
% The project struct.
% limits : struct
% The limits for each parameter.
%
% Returns
% -------
% problemStruct : struct
% The project struct with fit information.
fields = {"params", "backgroundParams", "scalefactors", "bulkIns",...
"bulkOuts", "resolutionParams", "domainRatios"};
titles = {"Parameter", "Background parameter", "Scalefactor", "Bulk in",...
"Bulk out", "Resolution parameter", "Domain ratio"};

for i = 1:length(fields)
fitIndices = find(problemStruct.checks.(fields{i}));

for j = 1:length(fitIndices)
lower = limits.(fields{i})(fitIndices(j),1);
upper = limits.(fields{i})(fitIndices(j),2);

if (upper - lower) < 1e-10
paramName = problemStruct.names.(fields{i}){fitIndices(j)};
warning('%s "%s" was removed from the fit because its range is too small (< 1e-10).', titles{i}, paramName);
problemStruct.checks.(fields{i})(fitIndices(j)) = 0;
end
end
end

end

3 changes: 3 additions & 0 deletions API/parseClassToStructs.m
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@
problemStruct.checks.domainRatios = ones(1,0);
end

if ~strcmpi(inputControls.procedure, procedures.Calculate.value)
problemStruct = checkRange(problemStruct, limits);
end
% Make sure the indices cannot lie outside of the arrays
checkIndices(problemStruct, inputStruct.files);

Expand Down
14 changes: 7 additions & 7 deletions API/parseOutToProjectClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,43 @@
%(1) Parameters
params = problemStruct.params;
for i = 1:length(params)
project.setParameter(i, 'value', params(i));
project.setParameter(i, 'value', params(i), 'fit', logical(problemStruct.checks.params(i)));
end

%(2) Backgrounds
backgroundParams = problemStruct.backgroundParams;
for i = 1:length(backgroundParams)
project.setBackgroundParam(i, 'value', backgroundParams(i));
project.setBackgroundParam(i, 'value', backgroundParams(i), 'fit', logical(problemStruct.checks.backgroundParams(i)));
end

%(3) Scalefactors
scalefactors = problemStruct.scalefactors;
for i = 1:length(scalefactors)
project.setScalefactor(i,'value',scalefactors(i));
project.setScalefactor(i,'value',scalefactors(i), 'fit', logical(problemStruct.checks.scalefactors(i)));
end

%(4) Bulk In
bulkIns = problemStruct.bulkIns;
for i = 1:length(bulkIns)
project.setBulkIn(i,'value',bulkIns(i));
project.setBulkIn(i,'value',bulkIns(i), 'fit', logical(problemStruct.checks.bulkIns(i)));
end

%(5) Bulk Out
bulkOuts = problemStruct.bulkOuts;
for i = 1:length(bulkOuts)
project.setBulkOut(i,'value',bulkOuts(i));
project.setBulkOut(i,'value',bulkOuts(i), 'fit', logical(problemStruct.checks.bulkOuts(i)));
end

%(6) Resolutions
resolutionParams = problemStruct.resolutionParams;
for i = 1:length(resolutionParams)
project.setResolutionParam(i,'value',resolutionParams(i));
project.setResolutionParam(i,'value',resolutionParams(i), 'fit', logical(problemStruct.checks.resolutionParams(i)));
end

% (7) Domain ratio
if strcmpi(problemStruct.TF, calculationTypes.Domains.value)
domainRatios = problemStruct.domainRatios;
for i = 1:length(domainRatios)
project.setDomainRatio(i,'value',domainRatios(i));
project.setDomainRatio(i,'value',domainRatios(i), 'fit', logical(problemStruct.checks.domainRatios(i)));
end
end
Loading