Mantid
Loading...
Searching...
No Matches
SpectrumDefinition.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#include "MantidTypes/SpectrumDefinition.h"
8
9#include <boost/python/class.hpp>
10#include <boost/python/tuple.hpp>
11
12using Mantid::SpectrumDefinition;
13using namespace boost::python;
14
15// Helper function to convert a std::Pair to a Python tuple
16boost::python::tuple toTuple(const SpectrumDefinition &self, const size_t index) {
17 const std::pair<size_t, size_t> pair = self.operator[](index);
18 return make_tuple(pair.first, pair.second);
19}
20
22 class_<SpectrumDefinition>("SpectrumDefinition", no_init)
23
24 .def("__getitem__", &toTuple, (arg("self"), arg("index")),
25 "Returns the pair of detector index and time index at given index "
26 "of spectrum definition.")
27
28 .def("__len__", &SpectrumDefinition::size, arg("self"),
29 "Returns the size of the SpectrumDefinition i.e. the number of "
30 "detectors for the spectrum.")
31
32 .def("size", &SpectrumDefinition::size, arg("self"),
33 "Returns the size of the SpectrumDefinition i.e. the number of "
34 "detectors for the spectrum.")
35
36 .def("add", &SpectrumDefinition::add, (arg("self"), arg("detectorIndex"), arg("timeIndex")),
37 "Adds a pair of detector index and time index to the spectrum "
38 "definition.")
39
40 .def("equals", &SpectrumDefinition::operator==, (arg("self"), arg("other")), "Compare spectrum definitions.");
41}
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
void export_SpectrumDefinition()
boost::python::tuple toTuple(const SpectrumDefinition &self, const size_t index)