-
Notifications
You must be signed in to change notification settings - Fork 126
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
37795 change polaris pdf norm #38535
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks for this, just a minor thing and a request to tidy up a function which you didn't write (but seeing as you are in the file anyway).
Also would it be possible to get a release note for this - we will want users to be aware of it (to that end we will also contact POLARIS scientists when it's merged)!
|
||
def validate(self): | ||
# check output files as expected | ||
def generate_error_message(expected_file, output_dir): |
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 like these functions are also in FocusTestNoAbsorptionWithRelativeNormalisation
- would it be possible to define them as helper functions once outside the test classes so they don't have to be duplicated?
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.
I've done this - I wasn't sure what variable to use for the passed class objects as self
seemed inappropriate for a general helper function - so I called it test
.
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.
Sorry I just meant the two functions generate_error_message
and assert_output_file_exists
being moved to external helper functions - but I now see the latter requires the test
object.
It is annoying with systems test that each test is it's own class, I have not seen the test class being passed in this way before but it works!
It might be overkill, put one possible solution is to define a new base class with these methods like so
class focus_system_test_helper(systemtesting.MantidSystemTest):
def _assert_output_file_exists(directory, filename):
test.assertTrue(os.path.isfile(os.path.join(directory, filename)), msg=generate_error_message(filename, directory))
def _assert_focus_output_files(ws_num):
user_output = os.path.join(output_dir, "17_1", "Test")
assert_output_file_exists(user_output, f"POLARIS{ws_num}.nxs")
assert_output_file_exists(user_output, f"POLARIS{ws_num}.gsas")
output_dat_dir = os.path.join(user_output, "dat_files")
for bankno in range(1, 6):
assert_output_file_exists(output_dat_dir, f"POL{ws_num}-b_{bankno}-TOF.dat")
assert_output_file_exists(output_dat_dir, f"POL{ws_num}-b_{bankno}-d.dat")
# outside class
def _generate_error_message(expected_file, output_dir):
return f"Unable to find {expected_file} in {output_dir}.\nContents={os.listdir(output_dir)}"
Then define the individual classes like so
class FocusTestNoAbsorptionWithAbsoluteNormalisation(focus_system_test_helper):
I'm pretty sure the test suite won't try to run the new base class, if you have time feel free to give it a go, otherwise happy to approve!
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.
It seems it does try and run the helper class, I guess because in inherits from systemtesting.MantidSystemTest
. I can get around it by putting it within another class which doesn't inherit. This work around allows more of the repeated code to be moved to the helper but is perhaps a bit hackier? I've added it as a commit, but let me know and we can roll back to the previous format
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.
Oh dear sorry! That does seem to be a bit hacky - one could also set the base class test to be skipped by overloading the skipTests method and returning True - but then this would be recorded as a skipped test!
If it's OK with you let's roll back and stick with what you had!
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.
Yeh, I saw that as an option but also didn't like the fact it would come up as a skipped test. Should be reverted now
@@ -534,7 +577,7 @@ def run_total_scattering( | |||
|
|||
|
|||
def _gen_required_files(): | |||
required_run_numbers = ["98531", "98532", "98533"] # create_van : PDF mode # File to focus (Si) | |||
required_run_numbers = ["98531", "98532", "98533", "98534"] # create_van : PDF mode # File to focus (Si) |
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.
I'm OK to have an additional file, but is there a reason why you couldn't use 98533
and just have a different reference file?
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.
Short answer is probably no, I'm sure there is a way that could've been done. I just tried to keep it consistent and it seemed that the old test took 98532 and ran the normalisation then compared it to 98533, so I figured we could run a different normalisation and compare it to 98534.
Some extra changes will be needed as this norm_dict doesn't seem to be called properly
Updated the enum to recognise the option and updated the tests so "Relative" is no longer hard coded - added an extra test some corresponding files
fbbbebe
to
512553a
Compare
I think all those comments have now been addressed? |
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.
One more thing that I should have thought about before sorry!
Can we update the Polaris reduction docs here?
Accepted values are: **PDF** or **Rietveld** |
docs/source/release/v6.12.0/Diffraction/Powder/New_features/38535.rst
Outdated
Show resolved
Hide resolved
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 the changes!
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.
Actually if you get chance could you clean up the commit history? Specifically instead of adding another separate commit to revert the previous one, could you do git rebase -i HEAD~4
and remove the commit(s)
a4f39ff
e0697c5
There may be another way in git, but that's what I use! It's good practice to keep it clean (I know it's my fault for suggesting changes that don't pan out!)
Sure, I did have a think about it before reverting and came to the conclusion that I wanted to have it in the commit history in case we changed our minds again (to still have the code accessible), but if you're happy for it to go, I am too |
Thanks, if you could go ahead that'd be great. |
f56991e
to
a3e4aad
Compare
Description of work
Summary of work
As per issue #37795 added an option for the vanadium normalisation to be done either using relative or absolute normalisation.
Fixes #37795.
Further detail of work
This is done by addition of a new mode "pdf_norm". In order to accommodate this some additional alterations were required to the enum class and the test files. An additional test was added to check the absolute normalisation.
To test:
Run the ISISPowder_PolarisTest.py tests. There should now be 18. The new tests FocusTestNoAbsorptionWithRelativeNormalisation and FocusTestNoAbsorptionWithAbsoluteNormalisation have replaced FocusTestNoAbsorption.
Reviewer
Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.
Code Review
Functional Tests
Does everything look good? Mark the review as Approve. A member of
@mantidproject/gatekeepers
will take care of it.Gatekeeper
If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.