Skip to content
Snippets Groups Projects
Commit 85ebc8f5 authored by Anton Piccardo-Selg's avatar Anton Piccardo-Selg
Browse files

Refs #13872 Add further unit detection to HKL

parent 10cbb0bf
No related merge requests found
......@@ -12,12 +12,14 @@
#include "MantidAPI/IMDWorkspace.h"
#include "MantidTestHelpers/FakeObjects.h"
#include "MantidAPI/NullCoordTransform.h"
#include "MantidGeometry/MDGeometry/QSample.h"
using namespace Mantid;
using namespace Mantid::Kernel;
using namespace Mantid::API;
using namespace Mantid::Geometry;
class MDGeometryTest : public CxxTest::TestSuite {
public:
// This pair of boilerplate methods prevent the suite being created statically
......@@ -28,8 +30,9 @@ public:
void test_initGeometry() {
MDGeometry g;
std::vector<IMDDimension_sptr> dims;
IMDDimension_sptr dim1(new MDHistoDimension("Qx", "Qx", "Ang", -1, +1, 10));
IMDDimension_sptr dim2(new MDHistoDimension("Qy", "Qy", "Ang", -1, +1, 20));
const Mantid::Geometry::QSample frame;
IMDDimension_sptr dim1(new MDHistoDimension("Qx", "Qx", frame, -1, +1, 10));
IMDDimension_sptr dim2(new MDHistoDimension("Qy", "Qy", frame, -1, +1, 20));
dims.push_back(dim1);
dims.push_back(dim2);
g.initGeometry(dims);
......@@ -86,8 +89,9 @@ public:
void test_copy_constructor() {
MDGeometry g;
std::vector<IMDDimension_sptr> dims;
IMDDimension_sptr dim0(new MDHistoDimension("Qx", "Qx", "Ang", -1, +1, 0));
IMDDimension_sptr dim1(new MDHistoDimension("Qy", "Qy", "Ang", -1, +1, 0));
const Mantid::Geometry::QSample frame;
IMDDimension_sptr dim0(new MDHistoDimension("Qx", "Qx", frame, -1, +1, 0));
IMDDimension_sptr dim1(new MDHistoDimension("Qy", "Qy", frame, -1, +1, 0));
dims.push_back(dim0);
dims.push_back(dim1);
g.initGeometry(dims);
......@@ -136,11 +140,12 @@ public:
/** Adding dimension info and searching for it back */
void test_addDimension_getDimension() {
MDGeometry g;
const Mantid::Geometry::QSample frame;
MDHistoDimension_sptr dim(
new MDHistoDimension("Qx", "Qx", "Ang", -1, +1, 0));
new MDHistoDimension("Qx", "Qx", frame, -1, +1, 0));
TS_ASSERT_THROWS_NOTHING(g.addDimension(dim);)
MDHistoDimension_sptr dim2(
new MDHistoDimension("Qy", "Qy", "Ang", -1, +1, 0));
new MDHistoDimension("Qy", "Qy", frame, -1, +1, 0));
TS_ASSERT_THROWS_NOTHING(g.addDimension(dim2);)
TS_ASSERT_EQUALS(g.getNumDims(), 2);
TS_ASSERT_EQUALS(g.getDimension(0)->getName(), "Qx");
......@@ -152,11 +157,12 @@ public:
void test_transformDimensions() {
MDGeometry g;
const Mantid::Geometry::QSample frame;
MDHistoDimension_sptr dim(
new MDHistoDimension("Qx", "Qx", "Ang", -1, +1, 0));
new MDHistoDimension("Qx", "Qx", frame, -1, +1, 0));
TS_ASSERT_THROWS_NOTHING(g.addDimension(dim);)
MDHistoDimension_sptr dim2(
new MDHistoDimension("Qy", "Qy", "Ang", -2, +2, 0));
new MDHistoDimension("Qy", "Qy", frame, -2, +2, 0));
TS_ASSERT_THROWS_NOTHING(g.addDimension(dim2);)
TS_ASSERT_EQUALS(g.getNumDims(), 2);
boost::shared_ptr<WorkspaceTester> ws(new WorkspaceTester());
......@@ -262,8 +268,9 @@ public:
void test_all_normalized() {
MDGeometry geometry;
std::vector<IMDDimension_sptr> dims;
IMDDimension_sptr dim1(new MDHistoDimension("Qx", "Qx", "Ang", -1, +1, 10));
IMDDimension_sptr dim2(new MDHistoDimension("Qy", "Qy", "Ang", -1, +1, 20));
const Mantid::Geometry::QSample frame;
IMDDimension_sptr dim1(new MDHistoDimension("Qx", "Qx", frame, -1, +1, 10));
IMDDimension_sptr dim2(new MDHistoDimension("Qy", "Qy", frame, -1, +1, 20));
dims.push_back(dim1);
dims.push_back(dim2);
geometry.initGeometry(dims);
......@@ -285,6 +292,7 @@ public:
TSM_ASSERT("All basis vectors are normalized",
geometry.allBasisNormalized());
}
};
#endif /* MANTID_API_MDGEOMETRYTEST_H_ */
......@@ -35,7 +35,13 @@ ReciprocalLatticeUnitFactory::createRaw(const std::string &) const {
bool ReciprocalLatticeUnitFactory::canInterpret(
const std::string &unitString) const {
return unitString == Units::Symbol::RLU.ascii();
auto isRLU = unitString == Units::Symbol::RLU.ascii();
// In addition to having RLU we can encounter units of type "in 6.28 A^-1"
// We need to account for the latter here
boost::regex pattern("in.*A\\^-1");
auto isHoraceStyle = boost::regex_match(unitString, pattern);
return isRLU || isHoraceStyle;
}
MDUnitFactory_uptr makeMDUnitFactoryChain() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment