-
Notifications
You must be signed in to change notification settings - Fork 128
Fix an error when exporting Sliceviewer pixel cuts from MDHisto workspaces #39071
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
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 the comprehensive tests!
Testing this manually there does appear to be a problem
The exported pixle cuts just look like straight lines because there's only two bins (you can see this by looking at mtd['md_3D_histo_cut_y
].getSingalArray()`
Also if there is an MDEvent workspace e.g. ws.hasOriginalWorkspace() = True
then we might want to call the MDEvent function which I think should go an call BinMD on the MDEvent workspace underneath (if it has same number of dimensions - i.e. not in this case as original workspace is 4D)? What do you think?
Great thanks! Plots look good, but the only way to know for certain is by checking the workspace history and the integration limits passed. I can check this tomorrow and re-review! |
Tested this - the y-cut looks good, but the x-cut still only has 2 points.
and y-cut
I think the x-cut (along H) should have |
Ah x cut seems to be OK if I export by pressing x-key, but not c-key on keyboard! |
Ohh now I can reproduce it, seems a problem with c key, I will fix it |
Exporting both cuts using C key should work well now |
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 - it looks like export_pixel_cut_to_workspace_mdhist
and export_pixel_cut_to_workspace_mdevent
are basically the same just calling a different function to do the actual cut (which calls different algorithms) is that right? Could we get away with one export_pixel_cut_to_workspace_md
which calls a class method which is wrapper around either self.export_cuts_to_workspace_mdhisto
or self.export_cuts_to_workspace_mdevent` depending on workspace type?
Yeah, there is a lot of duplicate code, I will merge them into one function as you suggest |
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.
Great, tested on MDEvent and MDHisto with transpose in 4D and 3D and all looking good - thanks for getting this over the line!
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.
Problem fixed, works fine. Just one question about one of the tests.
mock_extract_roi.assert_called_once_with(self.ws2d_histo, None, None, xpos, xpos, False, "ws2d_histo_cut_x") | ||
self.assertEqual("Cut along Y created: ws2d_histo_cut_x", help_msg) | ||
|
||
for cut_type in ("x", "y"): |
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.
Are there also supposed to be calls to assert_call_as_expected
with transpose=True
? Looks like the logic is there to handle it.
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.
Ohh thanks for spotting that, yeah will add transpose true cases
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 fixing the test.
…paces (mantidproject#39071) ### Description of work This PR fixes a bug encountered when exporting pixel cuts from MDHisto workspaces. The issue arose because the `export_pixel_cut_to_workspace` is assigned to the MDEvent version in the model. I have added a new function for performing pixel cuts from MDHisto workspaces. Additionally, I have added unit tests for the export pixel cut functions. <!-- Why has this work been done? If there is no linked issue please provide appropriate context for this work. #### Purpose of work This can be removed if a github issue is referenced below --> Fixes mantidproject#36084. <!-- and fix #xxxx or close #xxxx xor resolves #xxxx. One line per issue fixed. --> ### To test: 1- Make the workspace `md_3D_histo` ``` md_4D = CreateMDWorkspace(Dimensions=4, Extents=[0,2,-1,1,-1.5,1.5,-0.25,0.25], Names="H,K,L,E", Frames='HKL,HKL,HKL,General Frame',Units='r.l.u.,r.l.u.,r.l.u.,meV') FakeMDEventData(InputWorkspace=md_4D, UniformParams='5e5') # 4D data FakeMDEventData(InputWorkspace=md_4D, UniformParams='1e5,0.5,1.5,-0.5,0.5,-0.75,0.75,-0.1,0.1') # 4D data # Add a non-orthogonal UB expt_info = CreateSampleWorkspace() md_4D.addExperimentInfo(expt_info) SetUB(Workspace='md_4D', c=2, gamma=120) md_3D_histo = BinMD(InputWorkspace='md_4D', AlignedDim0='H,-2,2,100', AlignedDim1='K,-1,1,100', AlignedDim2='L,-1.5,1.5,100') ``` 2- Open `md_3D_histo` in sliceviewer 3- Select the plot option 4- Press 'x' or 'y' to create a new cut along that axis 5- Check if the cut is correct <!-- Instructions for testing. There should be sufficient instructions for someone unfamiliar with the application to test - unless a specific reviewer is requested. If instructions for replicating the fault are contained in the linked issue then it is OK to refer back to these. --> <!-- delete this if you added release notes *This does not require release notes* because **fill in an explanation of why** If you add release notes please save them as a separate file using the Issue or PR number as the file name. Check the file is located in the correct directory for your note(s). --> <!-- Ensure the base of this PR is correct (e.g. release-next or main) Finally, don't forget to add the appropriate labels, milestones, etc.! --> --- ### Reviewer Please comment on the points listed below ([full description](http://developer.mantidproject.org/ReviewingAPullRequest.html)). **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 - Is the code of an acceptable quality? - Does the code conform to the [coding standards](http://developer.mantidproject.org/Standards/)? - Are the unit tests small and test the class in isolation? - If there is GUI work does it follow the [GUI standards](http://developer.mantidproject.org/Standards/GUIStandards.html)? - If there are changes in the release notes then do they describe the changes appropriately? - Do the release notes conform to the [release notes guide](https://developer.mantidproject.org/Standards/ReleaseNotesGuide.html)? #### Functional Tests - Do changes function as described? Add comments below that describe the tests performed? - Do the changes handle unexpected situations, e.g. bad input? - Has the relevant (user and developer) documentation been added/updated? 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.
Description of work
This PR fixes a bug encountered when exporting pixel cuts from MDHisto workspaces. The issue arose because the
export_pixel_cut_to_workspace
is assigned to the MDEvent version in the model. I have added a new function for performing pixel cuts from MDHisto workspaces. Additionally, I have added unit tests for the export pixel cut functions.Fixes #36084.
To test:
1- Make the workspace
md_3D_histo
2- Open
md_3D_histo
in sliceviewer3- Select the plot option
4- Press 'x' or 'y' to create a new cut along that axis
5- Check if the cut is correct
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.