Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds code to ensure parameter array indices are valid #236

Merged
merged 7 commits into from
Jun 14, 2024

Conversation

DrPaulSharp
Copy link
Collaborator

No description provided.

qzshiftArray, scalefactorArray, bulkInArray, bulkOutArray, resolutionParamArray,...
domainRatioArray, dataPresent, nParams, params, ~, resample,...
contrastBackgroundActions, cCustFiles, useImaginary] = extractProblemParams(problemStruct);

checkIndices(contrastBackgroundIndices, contrastQzshiftIndices,...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to do this check earlier maybe in parseClassToStructs? This should reduce duplication and any chance of affecting performance. The function can take problemStruct as input also

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was cautious owing to the fact that the reflectivity calculation is performed numerous times within the minimisers, with changes to problemStruct. Having looked through carefully though, it seems like the changes made in unpackParams cannot affect the length of the parameter arrays, so we should be ok. Let me know if you can think of anything that might be affected though.

@@ -71,7 +71,7 @@
contrastBackgroundActions = cell(1,nContrasts);
contrastBulkIns = ones(1,nContrasts);
contrastBulkOuts = ones(1,nContrasts);
contrastDomainRatios = zeros(1,nContrasts);
contrastDomainRatios = ones(1,nContrasts);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why this is changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for consistency with the rest of the arrays and tests now that each entry is filled in or set to -1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just cautious we don't break something by changing the default. Is it possible one of the contrast does not have a domain ratio property but the value defaults to 1 now instead of the original 0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few lines further down, we loop through each contrast and set the value if the contrast has a domain ratio, or set it to -1. I therefore can't see any issue with this change. Having said that, I take your point that there is potential for problems with this default, so I'll change back. I'm inclined to think, especially with the check indices routine now present, that setting all of these to a default of zero is the better option. One to talk over on Monday maybe?

targetFunctions/+domainsTF/customXY.m Outdated Show resolved Hide resolved
targetFunctions/+domainsTF/standardLayers.m Outdated Show resolved Hide resolved
targetFunctions/common/checkIndices.m Outdated Show resolved Hide resolved
@DrPaulSharp DrPaulSharp merged commit 2257620 into RascalSoftware:master Jun 14, 2024
4 checks passed
@DrPaulSharp DrPaulSharp deleted the index branch June 14, 2024 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants