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
Conversation
@@ -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", |
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.
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> >
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.
Maybe the output has to be converted into a boost::python::list
?
Sometimes you have to write a wrapper like this
mantid/Framework/PythonInterface/mantid/geometry/src/Exports/PointGroup.cpp
Lines 35 to 44 in 573e47a
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; | |
} |
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.
Yes, you are right, I will add this converter
Just a couple of questions (I know this is a proof-of concept PR to see what breaks):
|
Framework/API/src/Sample.cpp
Outdated
throw std::runtime_error("Sample::getOrientedLattice - No OrientedLattice has been defined."); | ||
} | ||
return *m_lattice; | ||
return (*m_lattices)[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.
Ah yes I see it returns the first element!
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.
- yes, they will return the same object,
getOrientedLattice
will always return the first element. Also, note thatsetOrientedLattice
will reset the list and add one lattice to it, this behaviour is defined to ensure backward compatibility. You can set multiple oriented lattices usingsetOrientedLattices
. - yes, it will always return the first element
535bd41
to
f52c69c
Compare
c4bd5a7
to
06ab306
Compare
da2ef25
to
79ae214
Compare
👋 Hi, @MohamedAlmaki, Conflicts have been detected against the base branch. Please rebase your branch against the base branch. |
Closed as we have changed our approach to #37166 |
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
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.