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

38254 Introducing PeakShapeDetectorBin peak shape #38433

Merged
merged 6 commits into from
Dec 11, 2024

Conversation

warunawickramasingha
Copy link
Contributor

@warunawickramasingha warunawickramasingha commented Nov 21, 2024

Description of work

A new peak shape PeakShapeDetectorBin was introduced to save the shape of each peak including the detector IDs and limits of either TOF or dSpacing. This shape can be used for

  • Overlap detection post integration (peaks could be excluded or flagged as combined)
  • Two-step integration - re-integrate weak peaks using strong peak dimensions
  • Eventual visualisation on instrument view (i.e. show bounding box of peak)

Partially fixes #38254.

Further detail of work

To test:

  1. Code review
  2. Unit tests should pass in python and c++
  3. PeakShapeDetectorBin should be visible to python and can be inspected with below code snippet
from mantid.dataobjects import PeakShapeDetectorBin
from mantid.kernel import SpecialCoordinateSystem
detBinList = [(101, 27.0, 100.0), (202, 3000.0, 5000.0)]
shape = PeakShapeDetectorBin(detBinList, SpecialCoordinateSystem.NONE, "ParentAlgoName", 1)
print(shape.toJSON())
print(shape.algorithmName())
print(shape.algorithmVersion())
print(shape.shapeName())

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

  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards?
  • Are the unit tests small and test the class in isolation?
  • If there is GUI work does it follow the GUI standards?
  • 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?

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.

@warunawickramasingha warunawickramasingha added Diffraction Issues and pull requests related to diffraction Single Crystal Issues and pull requests related to single crystal labels Nov 21, 2024
@warunawickramasingha warunawickramasingha added this to the Release 6.12 milestone Nov 21, 2024
Copy link
Contributor

@GuiMacielPereira GuiMacielPereira left a comment

Choose a reason for hiding this comment

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

The code looks good and the unit tests are comprehensive. The script provided for testing runs without issue.
I have only a few requests and I noticed that the == is not quite working?
When I run

from mantid.dataobjects import PeakShapeDetectorBin
from mantid.kernel import SpecialCoordinateSystem
detBinList = [(101, 27.0, 100.0), (202, 3000.0, 5000.0)]
shape1 = PeakShapeDetectorBin(detBinList, SpecialCoordinateSystem.NONE, "ParentAlgoName", 1)
shape2 = PeakShapeDetectorBin(detBinList, SpecialCoordinateSystem.NONE, "ParentAlgoName", 1)
print(shape1==shape2)

It prints False, but from the code it looks like the intention is to print True?
Unless I misunderstood in which case you can ignore this.

@warunawickramasingha
Copy link
Contributor Author

The code looks good and the unit tests are comprehensive. The script provided for testing runs without issue. I have only a few requests and I noticed that the == is not quite working? When I run

from mantid.dataobjects import PeakShapeDetectorBin
from mantid.kernel import SpecialCoordinateSystem
detBinList = [(101, 27.0, 100.0), (202, 3000.0, 5000.0)]
shape1 = PeakShapeDetectorBin(detBinList, SpecialCoordinateSystem.NONE, "ParentAlgoName", 1)
shape2 = PeakShapeDetectorBin(detBinList, SpecialCoordinateSystem.NONE, "ParentAlgoName", 1)
print(shape1==shape2)

It prints False, but from the code it looks like the intention is to print True? Unless I misunderstood in which case you can ignore this.

Thanks for the detailed review @GuiMacielPereira !
The above observation was because the operator== was not exposed to python's __eq__ method.

The same behaviour can be observed in the existing peak shapes such as PeakShapeEllipsoid, PeakShapeSpherical from python. You could try that by

from mantid.dataobjects import PeakShapeSpherical, PeakShapeEllipsoid
sphere1 = PeakShapeSpherical(0.5)
sphere2 = PeakShapeSpherical(0.5)
print(sphere1 == sphere2)  # <-- False

ellipse1 = PeakShapeEllipsoid([V3D(1, 0, 0), V3D(0, 1, 0), V3D(0, 0, 1)], [0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9])
ellipse2 = PeakShapeEllipsoid([V3D(1, 0, 0), V3D(0, 1, 0), V3D(0, 0, 1)], [0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9])
print(ellipse1 == ellipse2) # <-- False

However I have fixed this for PeakShapeDetectorBin and would now output True in your example.

Copy link
Contributor

@GuiMacielPereira GuiMacielPereira left a comment

Choose a reason for hiding this comment

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

Thank you for your explanation, I think we should keep __eq__ doing the same thing as the other classes. If you change it back and the tests pass, I'll be happy to aprove.
Apologies for my oversight

Copy link
Contributor

@GuiMacielPereira GuiMacielPereira left a comment

Choose a reason for hiding this comment

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

All good, thanks for changing the equality back!

@robertapplin robertapplin self-assigned this Dec 11, 2024
@robertapplin robertapplin merged commit 32bc656 into main Dec 11, 2024
10 checks passed
@robertapplin robertapplin deleted the 38254_saving_peak_shape branch December 11, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Diffraction Issues and pull requests related to diffraction Single Crystal Issues and pull requests related to single crystal
Projects
Status: Merged
Status: Done
3 participants