Skip to content

Comments

Adds code to ensure parameter array indices are valid#236

Merged
DrPaulSharp merged 7 commits intoRascalSoftware:masterfrom
DrPaulSharp:index
Jun 14, 2024
Merged

Adds code to ensure parameter array indices are valid#236
DrPaulSharp merged 7 commits intoRascalSoftware:masterfrom
DrPaulSharp:index

Conversation

@DrPaulSharp
Copy link
Collaborator

No description provided.

@DrPaulSharp DrPaulSharp requested a review from StephenNneji June 13, 2024 13:04
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.

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?

@DrPaulSharp DrPaulSharp merged commit 2257620 into RascalSoftware:master Jun 14, 2024
@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