Mantid
Loading...
Searching...
No Matches
UnitConversion.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 +
8#include <boost/python/class.hpp>
9#include <boost/python/suite/indexing/map_indexing_suite.hpp>
10
13using namespace boost::python;
14
15double deprecatedSignature(const std::string &src, const std::string &dest, const double srcValue, const double l1,
16 const double l2, const double theta, const DeltaEMode::Type emode, const double efixed) {
17 PyErr_Warn(PyExc_DeprecationWarning, ".run(src, dest, srcValue, l1, l2, theta, emode, efixed) is deprecated. "
18 "Use .run(src, dest, srcValue, l1, emode, params) instead.");
19 return UnitConversion::run(src, dest, srcValue, l1, l2, theta, emode, efixed);
20}
21
23 // Function pointer typedef
24 using newStringVersion = double (*)(const std::string &, const std::string &, const double, const double,
26
27 class_<std::unordered_map<Mantid::Kernel::UnitParams, double>>("UnitParametersMap")
28 .def(map_indexing_suite<std::unordered_map<Mantid::Kernel::UnitParams, double>>());
29
30 class_<UnitConversion, boost::noncopyable>("UnitConversion", no_init)
31 .def("run", &deprecatedSignature,
32 (arg("src"), arg("dest"), arg("srcValue"), arg("l1"), arg("l2"), arg("theta"), arg("emode"), arg("efixed")),
33 "Performs a unit conversion on a single value (deprecated).")
34 .def("run", (newStringVersion)&UnitConversion::run,
35 (arg("src"), arg("dest"), arg("srcValue"), arg("l1"), arg("emode"), arg("params")),
36 "Performs a unit conversion on a single value.")
37 .staticmethod("run");
38}
double deprecatedSignature(const std::string &src, const std::string &dest, const double srcValue, const double l1, const double l2, const double theta, const DeltaEMode::Type emode, const double efixed)
void export_UnitConversion()
A set of static helper methods to perform conversions between units.
static double run(const std::string &src, const std::string &dest, const double srcValue, const double l1, const double l2, const double theta, const DeltaEMode::Type emode, const double efixed)
Convert a single value between the given units (as strings)
std::unordered_map< UnitParams, double > UnitParametersMap
Definition: Unit.h:30
Defines the possible energy transfer modes:
Definition: DeltaEMode.h:23
Type
Define the available energy transfer modes It is important to assign enums proper numbers,...
Definition: DeltaEMode.h:29