From 57bc998d6d244e82dd7b19dc686d26101d3c5ffc Mon Sep 17 00:00:00 2001
From: Anton Piccardo-Selg <anton.piccardo-selg@tessella.com>
Date: Sun, 18 Oct 2015 16:32:50 +0100
Subject: [PATCH] Refs #13872 md frame factory with horace style

---
 Framework/Geometry/src/MDGeometry/MDFrameFactory.cpp | 12 ++++++++----
 Framework/Geometry/test/MDFrameFactoryTest.h         |  4 ++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/Framework/Geometry/src/MDGeometry/MDFrameFactory.cpp b/Framework/Geometry/src/MDGeometry/MDFrameFactory.cpp
index 2726cddd92c..bf558f0d064 100644
--- a/Framework/Geometry/src/MDGeometry/MDFrameFactory.cpp
+++ b/Framework/Geometry/src/MDGeometry/MDFrameFactory.cpp
@@ -3,7 +3,7 @@
 #include "MantidKernel/MDUnit.h"
 #include "MantidKernel/UnitLabelTypes.h"
 #include "MantidGeometry/MDGeometry/MDFrame.h"
-
+#include <boost/regex.hpp>
 namespace Mantid {
 namespace Geometry {
 
@@ -58,9 +58,13 @@ bool HKLFrameFactory::canInterpret(const MDFrameArgument &argument) const {
   auto unitFactoryChain = Kernel::makeMDUnitFactoryChain();
   auto mdUnit = unitFactoryChain->create(argument.unitString);
   // We expect units to be RLU or A^-1
-  const bool compatibleUnit =
-      (mdUnit->getUnitLabel() == Units::Symbol::InverseAngstrom ||
-       mdUnit->getUnitLabel() == Units::Symbol::RLU);
+  auto isInverseAngstrom =
+      mdUnit->getUnitLabel() == Units::Symbol::InverseAngstrom;
+  auto isRLU = mdUnit->getUnitLabel() == Units::Symbol::RLU;
+  boost::regex pattern("in.*A.*\\^-1");
+  auto isHoraceStyle =
+      boost::regex_match(mdUnit->getUnitLabel().ascii(), pattern);
+  const bool compatibleUnit = isInverseAngstrom || isRLU || isHoraceStyle;
   // Check both the frame name and the unit name
   return argument.frameString == HKL::HKLName && compatibleUnit;
 }
diff --git a/Framework/Geometry/test/MDFrameFactoryTest.h b/Framework/Geometry/test/MDFrameFactoryTest.h
index e50d8015a1a..8032c178dd1 100644
--- a/Framework/Geometry/test/MDFrameFactoryTest.h
+++ b/Framework/Geometry/test/MDFrameFactoryTest.h
@@ -104,6 +104,10 @@ public:
     TSM_ASSERT("Should offer to produce HKL products",
                factory.canInterpret(
                    MDFrameArgument(HKL::HKLName, Units::Symbol::RLU)));
+
+    TSM_ASSERT(
+        "Should offer to produce HKL products",
+        factory.canInterpret(MDFrameArgument(HKL::HKLName, "in 1.684 A^-1")));
   }
 
   void test_HKLFrameFactory_create_inverse_angstroms() {
-- 
GitLab