From 053088a74724ae241deb5e3dc89c8056ab3b3091 Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Tue, 11 Mar 2025 19:12:35 -0400 Subject: [PATCH] Exposing more methods to python --- .../mantid/geometry/src/Exports/Instrument.cpp | 7 +++++++ .../test/python/mantid/geometry/InstrumentTest.py | 14 ++++++++++++++ .../v6.13.0/Framework/Python/New_features/.gitkeep | 0 .../Framework/Python/New_features/39044.rst | 1 + 4 files changed, 22 insertions(+) delete mode 100644 docs/source/release/v6.13.0/Framework/Python/New_features/.gitkeep create mode 100644 docs/source/release/v6.13.0/Framework/Python/New_features/39044.rst diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp index 0e883c92a9c0..0d13d6b717d8 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp @@ -11,6 +11,7 @@ #include "MantidPythonInterface/core/Policies/RemoveConst.h" #include +#include #include #include @@ -74,6 +75,12 @@ void export_Instrument() { "Return the valid to :class:`~mantid.kernel.DateAndTime` of the " "instrument") + .def("getFilename", &Instrument::getFilename, arg("self"), return_value_policy(), + "Return the name of the file that the original IDF was from") + + .def("setFilename", &Instrument::setFilename, (arg("self"), arg("filename")), + "Set the name of the file that the original IDF was from") + .def("getBaseInstrument", &Instrument::baseInstrument, arg("self"), return_value_policy(), "Return reference to the base instrument") diff --git a/Framework/PythonInterface/test/python/mantid/geometry/InstrumentTest.py b/Framework/PythonInterface/test/python/mantid/geometry/InstrumentTest.py index d670506bef64..d4f77dccc2f3 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/InstrumentTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/InstrumentTest.py @@ -44,6 +44,20 @@ def test_getReferenceFrame(self): frame = self.__testws.getInstrument().getReferenceFrame() self.assertTrue(isinstance(frame, ReferenceFrame)) + def test_getFilename(self): + inst = self.__testws.getInstrument() + + # get the filename + NAME_ORIG = inst.getFilename() + + # check that the filename can be set + NAME_NEW = "testable" + inst.setFilename(NAME_NEW) + self.assertEqual(inst.getFilename(), NAME_NEW) + + # put the filename back to what it was + inst.setFilename(NAME_ORIG) + def test_ValidDates(self): inst = self.__testws.getInstrument() valid_from = inst.getValidFromDate() diff --git a/docs/source/release/v6.13.0/Framework/Python/New_features/.gitkeep b/docs/source/release/v6.13.0/Framework/Python/New_features/.gitkeep deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/docs/source/release/v6.13.0/Framework/Python/New_features/39044.rst b/docs/source/release/v6.13.0/Framework/Python/New_features/39044.rst new file mode 100644 index 000000000000..12d172ac6424 --- /dev/null +++ b/docs/source/release/v6.13.0/Framework/Python/New_features/39044.rst @@ -0,0 +1 @@ +- Exposed ``Instrument.getFilename()`` and ``Instrument.setFilename()`` to python