-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add Data and Function Background types #276
Add Data and Function Background types #276
Conversation
33dd23a
to
0c5efdf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are required for the new routine "constructBackground". At present our examples and test data consider only constant backgrounds, so our data to test the function section here is limited. How should we approach testing for this routine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good please see comments. I think its fine if constructBackground
has no test as its being called by the example tests but if you are up for it we could save the inputs and output that goes in to the function from the two examples and have its own independent test. What I would like in the future is some kind of validation (maybe from ORSO) for the background stuff
examples/miscellaneous/backgroundTypes/DSPCScriptWithFunctionBackground.m
Outdated
Show resolved
Hide resolved
examples/miscellaneous/backgroundTypes/DSPCScriptWithDataBackground.m
Outdated
Show resolved
Hide resolved
…kgroundTypes' - this will be the example folder for this
…does not compile)
… background array instead
ae2894a
to
01ce884
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good please see comments, in addition to previous comments about the resolutionsClass
examples/miscellaneous/backgroundTypes/DSPCScriptWithDataBackground.m
Outdated
Show resolved
Hide resolved
examples/miscellaneous/backgroundTypes/DSPCScriptWithFunctionBackground.m
Outdated
Show resolved
Hide resolved
API/projectClass/backgroundsClass.m
Outdated
if ~isempty(source) | ||
if strcmpi(inputBlock.type, allowedTypes.Constant.value) | ||
source = obj.validateParam(source, obj.backgroundParams.getNames(), 'Background Param'); | ||
maxValues = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maxValues
is used in multiple places might be worth making a private/constant struct with these values are reusing that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, Thanks for persevering on this one.
This enables data and function background types. In the compiled code, we construct a background array over the same range of q points that is used for the simulation, which replaces
backgroundParams
in the output.Constant backgrounds are now a constant array made in
constructBackground
.Data backgrounds are defined in the data block of the project and appended to the contrast data in
insertDataBackgroundIntoContrastData
(called inparseClassToStructs
), with an optional offset added inconstructBackground
.Function backgrounds are defined in the custom files block of the project and evaluated and applied in
constructBackground
. Note that only MATLAB background functions are supported at present.The API for backgrounds and resolutions has changed. We have added the field "source" which contains either the background/resolution parameter, entry in the data block, or entry in the custom file block for constant, data, and function backgrounds respectively. This differentiates this field from the five "value" fields, which now ONLY contain background parameters (the optional offset for data, and up to five function parameters).
NOTE - I'm not entirely sure about the name "source" for this field, feedback on something better is welcome. I've kept it at five value fields, meaning a function background can have up to five arguments, which feels sensible to me.