Skip to content

Commit 9d74eb3

Browse files
Exposing more methods to python
1 parent 06a2255 commit 9d74eb3

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "MantidPythonInterface/core/Policies/RemoveConst.h"
1212

1313
#include <boost/python/class.hpp>
14+
#include <boost/python/copy_const_reference.hpp>
1415
#include <boost/python/overloads.hpp>
1516
#include <boost/python/register_ptr_to_python.hpp>
1617

@@ -74,6 +75,12 @@ void export_Instrument() {
7475
"Return the valid to :class:`~mantid.kernel.DateAndTime` of the "
7576
"instrument")
7677

78+
.def("getFilename", &Instrument::getFilename, arg("self"), return_value_policy<copy_const_reference>(),
79+
"Return the name of the file that the original IDF was from")
80+
81+
.def("setFilename", &Instrument::setFilename, (arg("self"), arg("filename")),
82+
"Return the name of the file that the original IDF was from")
83+
7784
.def("getBaseInstrument", &Instrument::baseInstrument, arg("self"), return_value_policy<RemoveConstSharedPtr>(),
7885
"Return reference to the base instrument")
7986

Framework/PythonInterface/test/python/mantid/geometry/InstrumentTest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ def test_getReferenceFrame(self):
4444
frame = self.__testws.getInstrument().getReferenceFrame()
4545
self.assertTrue(isinstance(frame, ReferenceFrame))
4646

47+
def test_getFilename(self):
48+
inst = self.__testws.getInstrument()
49+
50+
# get the filename
51+
NAME_ORIG = inst.getFilename()
52+
53+
# check that the filename can be set
54+
NAME_NEW = "testable"
55+
inst.setFilename(NAME_NEW)
56+
self.assertEqual(inst.getFilename(), NAME_NEW)
57+
58+
# put the filename back to what it was
59+
inst.setFilename(NAME_ORIG)
60+
4761
def test_ValidDates(self):
4862
inst = self.__testws.getInstrument()
4963
valid_from = inst.getValidFromDate()

docs/source/release/v6.13.0/Framework/Python/New_features/.gitkeep

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Exposed ``Instrument.getFilename()`` and ``Instrument.setFilename()`` to python

0 commit comments

Comments
 (0)