Mantid
Loading...
Searching...
No Matches
IMDDimension.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 +
12#include <memory>
13
14#include <boost/python/class.hpp>
15#include <boost/python/copy_const_reference.hpp>
16#include <boost/python/register_ptr_to_python.hpp>
17#include <boost/python/return_internal_reference.hpp>
18
19using namespace Mantid::Geometry;
20using namespace boost::python;
21
23
24GNU_DIAG_OFF("strict-aliasing")
25
26namespace {
31std::string getUnitsAsStr(const IMDDimension &self) { return self.getUnits().ascii(); }
32
38std::shared_ptr<MDFrame> getMDFrame(const IMDDimension &self) {
39 return std::shared_ptr<MDFrame>(self.getMDFrame().clone());
40}
41} // namespace
42
43//--------------------------------------------------------------------------------------
44// Deprecated function
45//--------------------------------------------------------------------------------------
50std::string getName(const IMDDimension &self) {
51 PyErr_Warn(PyExc_DeprecationWarning, ".getName() is deprecated. Use .name instead.");
52 return self.getName();
53}
54
56 register_ptr_to_python<std::shared_ptr<IMDDimension>>();
57
58 class_<IMDDimension, boost::noncopyable>("IMDDimension", no_init)
59 .def("getName", &getName, arg("self"),
60 "Return the name of the dimension "
61 "as can be displayed along the "
62 "axis")
63 .add_property("name", &IMDDimension::getName,
64 "Return the name of the dimension as can be displayed "
65 "along the axis")
66 .def("getMaximum", &IMDDimension::getMaximum, arg("self"), "Return the maximum extent of this dimension")
67 .def("getMinimum", &IMDDimension::getMinimum, arg("self"), "Return the maximum extent of this dimension")
68 .def("getNBins", &IMDDimension::getNBins, arg("self"),
69 "Return the number of bins dimension have (an integrated has one). "
70 "A axis directed along dimension would have getNBins+1 axis points.")
71 .def("getNBoundaries", &IMDDimension::getNBoundaries, arg("self"),
72 "Return the number of bins boundaries (axis points) dimension have "
73 "(an integrated has two). "
74 "A axis directed along dimension would have getNBins+1 axis points.")
75 .def("getX", &IMDDimension::getX, (arg("self"), arg("ind")), "Return coordinate of the axis at the given index")
76 .def("getBinWidth", &IMDDimension::getBinWidth, arg("self"), "Return the width of each bin.")
77 .def("getDimensionId", &IMDDimension::getDimensionId, arg("self"), return_value_policy<copy_const_reference>(),
78 "Return a short name which identify the dimension among other "
79 "dimension."
80 "A dimension can be usually find by its ID and various ")
81 .def("getUnits", &getUnitsAsStr, arg("self"), "Return the units associated with this dimension.")
82 .def("getMDFrame", &getMDFrame, arg("self"), "Return the multidimensional frame for this dimension.");
83}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition: GetPointer.h:17
void export_IMDDimension()
std::string getName(const IMDDimension &self)
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
The class describes one dimension of multidimensional dataset representing an orthogonal dimension an...
Definition: IMDDimension.h:39
virtual coord_t getMaximum() const =0
virtual coord_t getMinimum() const =0
virtual std::string getName() const =0
virtual const Geometry::MDFrame & getMDFrame() const =0
virtual const Kernel::UnitLabel getUnits() const =0
virtual const std::string & getDimensionId() const =0
short name which identify the dimension among other dimension.
virtual coord_t getBinWidth() const
Definition: IMDDimension.h:88
virtual coord_t getX(size_t ind) const =0
virtual size_t getNBoundaries() const =0
virtual size_t getNBins() const =0
virtual MDFrame * clone() const =0
const AsciiString & ascii() const
Return an ascii label for unit.
Definition: UnitLabel.cpp:105