From 0b8fab94d6722b8f687121cea83645461257e659 Mon Sep 17 00:00:00 2001 From: Owen Arnold <owen.arnold@stfc.ac.uk> Date: Wed, 1 Apr 2020 22:13:09 +0100 Subject: [PATCH] Expose via Sample __eq__ --- .../PythonInterface/mantid/api/src/Exports/Sample.cpp | 3 ++- .../PythonInterface/test/python/mantid/api/SampleTest.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Framework/PythonInterface/mantid/api/src/Exports/Sample.cpp b/Framework/PythonInterface/mantid/api/src/Exports/Sample.cpp index c8f153e8715..ffba827eca1 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/Sample.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/Sample.cpp @@ -87,5 +87,6 @@ void export_Sample() { return_internal_reference<>()) .def("__copy__", &Mantid::PythonInterface::generic__copy__<Sample>) .def("__deepcopy__", - &Mantid::PythonInterface::generic__deepcopy__<Sample>); + &Mantid::PythonInterface::generic__deepcopy__<Sample>) + .def("__eq__", &Sample::operator==,(arg("self"), arg("other"))); } diff --git a/Framework/PythonInterface/test/python/mantid/api/SampleTest.py b/Framework/PythonInterface/test/python/mantid/api/SampleTest.py index 845075019e5..f3f7244902d 100644 --- a/Framework/PythonInterface/test/python/mantid/api/SampleTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/SampleTest.py @@ -124,8 +124,12 @@ class SampleTest(unittest.TestCase): def test_deep_copyable(self): self.do_test_copyable(copy.deepcopy) - - + def test_equals(self): + a = Sample() + b = Sample() + self.assertEqual(a, b) + b.setThickness(10) + self.assertNotEqual(a, b) if __name__ == '__main__': unittest.main() -- GitLab