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

Add support for multiple oriented lattices to Sample API #36654

Closed
wants to merge 15 commits into from

Conversation

MohamedAlmaki
Copy link
Contributor

@MohamedAlmaki MohamedAlmaki commented Jan 15, 2024

Description of work

This pull request modifies the Sample class by adding APIs to manage multiple oriented lattices for a single sample. The purpose of this addition is to enable a sample to store multiple UB matrices, which would allow different peak algorithms to use them. This PR will resolve part of #36592.

To test:

TBA


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.

@@ -35,7 +35,10 @@ void export_Sample() {
.def("getName", &Sample::getName, return_value_policy<copy_const_reference>(), arg("self"),
"Returns the string name of the sample")
.def("getOrientedLattice", (const OrientedLattice &(Sample::*)() const) & Sample::getOrientedLattice, arg("self"),
return_value_policy<reference_existing_object>(), "Get the oriented lattice for this sample")
return_value_policy<reference_existing_object>(), "Get the first oriented lattice for this sample")
.def("getOrientedLattices",
Copy link
Contributor

Choose a reason for hiding this comment

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

When I try ws.sample().getOrientedLattices() I get this error

TypeError: No Python class registered for C++ class class std::vector<class Mantid::Geometry::OrientedLattice,class std::allocator<class Mantid::Geometry::OrientedLattice> >

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the output has to be converted into a boost::python::list?
Sometimes you have to write a wrapper like this

boost::python::list getEquivalents(const PointGroup &self, const object &hkl) {
const auto &equivalents = self.getEquivalents(Converters::PyObjectToV3D(hkl)());
boost::python::list pythonEquivalents;
for (const auto &equivalent : equivalents) {
pythonEquivalents.append(equivalent);
}
return pythonEquivalents;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right, I will add this converter

@RichardWaiteSTFC
Copy link
Contributor

RichardWaiteSTFC commented Jan 16, 2024

Just a couple of questions (I know this is a proof-of concept PR to see what breaks):

  1. If a user creates a single OrientedLattice on a workspace using e.g. SetUB is the idea that both getOrientedLattice() and getOrientedLAttices()[0] would point to the same object?

  2. If a user adds another UB (method to be determined) - will getOrientedLattice() always point at the first or last added object

throw std::runtime_error("Sample::getOrientedLattice - No OrientedLattice has been defined.");
}
return *m_lattice;
return (*m_lattices)[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes I see it returns the first element!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. yes, they will return the same object, getOrientedLattice will always return the first element. Also, note that setOrientedLattice will reset the list and add one lattice to it, this behaviour is defined to ensure backward compatibility. You can set multiple oriented lattices using setOrientedLattices.
  2. yes, it will always return the first element

@github-actions github-actions bot added the Has Conflicts Used by the bot to label pull requests that have conflicts label Jan 31, 2024
Copy link

👋 Hi, @MohamedAlmaki,

Conflicts have been detected against the base branch. Please rebase your branch against the base branch.

@MohamedAlmaki
Copy link
Contributor Author

Closed as we have changed our approach to #37166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Has Conflicts Used by the bot to label pull requests that have conflicts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants