Skip to content
Snippets Groups Projects
Commit 42b3e3a7 authored by Samuel Jackson's avatar Samuel Jackson
Browse files

Refs #19349 Expose methods on SpaceGroup

parent 78c6be94
No related branches found
No related tags found
No related merge requests found
...@@ -98,6 +98,8 @@ protected: ...@@ -98,6 +98,8 @@ protected:
std::string m_hmSymbol; std::string m_hmSymbol;
}; };
MANTID_GEOMETRY_DLL std::ostream& operator<<(std::ostream& stream, const SpaceGroup& self);
typedef boost::shared_ptr<SpaceGroup> SpaceGroup_sptr; typedef boost::shared_ptr<SpaceGroup> SpaceGroup_sptr;
typedef boost::shared_ptr<const SpaceGroup> SpaceGroup_const_sptr; typedef boost::shared_ptr<const SpaceGroup> SpaceGroup_const_sptr;
......
...@@ -108,5 +108,11 @@ Group_const_sptr SpaceGroup::getSiteSymmetryGroup(const V3D &position) const { ...@@ -108,5 +108,11 @@ Group_const_sptr SpaceGroup::getSiteSymmetryGroup(const V3D &position) const {
return GroupFactory::create<Group>(siteSymmetryOps); return GroupFactory::create<Group>(siteSymmetryOps);
} }
std::ostream& operator<<(std::ostream& stream, const SpaceGroup& self) {
stream << "Space group with Hermann–Mauguin symbol: " << self.hmSymbol();
return stream;
}
} // namespace Geometry } // namespace Geometry
} // namespace Mantid } // namespace Mantid
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <boost/python/enum.hpp> #include <boost/python/enum.hpp>
#include <boost/python/scope.hpp> #include <boost/python/scope.hpp>
#include <boost/python/list.hpp> #include <boost/python/list.hpp>
#include <boost/python/self.hpp>
#include <boost/python/operators.hpp>
#include <boost/python/register_ptr_to_python.hpp> #include <boost/python/register_ptr_to_python.hpp>
using Mantid::Geometry::Group; using Mantid::Geometry::Group;
...@@ -48,6 +50,15 @@ Mantid::Geometry::Group_sptr getSiteSymmetryGroup(SpaceGroup &self, ...@@ -48,6 +50,15 @@ Mantid::Geometry::Group_sptr getSiteSymmetryGroup(SpaceGroup &self,
return group; return group;
} }
std::string __repr__implementation(const SpaceGroup& self) {
std::stringstream ss;
ss << "SpaceGroupFactory.createSpaceGroup(\"";
ss << self.hmSymbol();
ss << "\")";
return ss.str();
}
} }
void export_SpaceGroup() { void export_SpaceGroup() {
...@@ -71,5 +82,7 @@ void export_SpaceGroup() { ...@@ -71,5 +82,7 @@ void export_SpaceGroup() {
"Returns the point group of the space group.") "Returns the point group of the space group.")
.def("getSiteSymmetryGroup", &getSiteSymmetryGroup, .def("getSiteSymmetryGroup", &getSiteSymmetryGroup,
(arg("self"), arg("position")), (arg("self"), arg("position")),
"Returns the site symmetry group for supplied point coordinates."); "Returns the site symmetry group for supplied point coordinates.")
.def(str(self))
.def("__repr__", &__repr__implementation);
} }
...@@ -141,6 +141,20 @@ class SpaceGroupTest(unittest.TestCase): ...@@ -141,6 +141,20 @@ class SpaceGroupTest(unittest.TestCase):
spaceGroup = SpaceGroupFactory.createSpaceGroup("F -4 3 c") spaceGroup = SpaceGroupFactory.createSpaceGroup("F -4 3 c")
self.checkWyckoffPositions(spaceGroup, wyckoffs) self.checkWyckoffPositions(spaceGroup, wyckoffs)
def test_to_string(self):
spaceGroup = SpaceGroupFactory.createSpaceGroup("F -4 3 c")
expected_str = "Space group with Hermann\xe2\x80\x93Mauguin symbol: "\
"F -4 3 c"
expected_repr = "SpaceGroupFactory.createSpaceGroup(\"F -4 3 c\")"
self.assertEqual(expected_str, str(spaceGroup))
self.assertEqual(expected_repr, spaceGroup.__repr__())
newSpaceGroup = eval(spaceGroup.__repr__())
self.assertEqual(spaceGroup.getHMSymbol(), newSpaceGroup.getHMSymbol())
def checkWyckoffPositions(self, spaceGroup, wyckoffs): def checkWyckoffPositions(self, spaceGroup, wyckoffs):
for wp in wyckoffs: for wp in wyckoffs:
equivalentPositions = spaceGroup.getEquivalentPositions(wp[0]) equivalentPositions = spaceGroup.getEquivalentPositions(wp[0])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment