From 910ea28542f44fc34dd6cfd80cdbc1f3e8b53ab0 Mon Sep 17 00:00:00 2001
From: Antti Soininen <soininen@ill.fr>
Date: Mon, 2 Jul 2018 10:54:20 +0200
Subject: [PATCH] directtools: add a unit test. Re #22718

---
 scripts/test/directtools/DirectToolsTest.py | 24 ++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/scripts/test/directtools/DirectToolsTest.py b/scripts/test/directtools/DirectToolsTest.py
index 7e6d634bbef..78ba7fcd568 100644
--- a/scripts/test/directtools/DirectToolsTest.py
+++ b/scripts/test/directtools/DirectToolsTest.py
@@ -7,7 +7,8 @@ matplotlib.use('AGG')
 
 import directtools
 from mantid.api import mtd
-from mantid.simpleapi import LoadILLTOF, CreateSampleWorkspace, CreateWorkspace
+from mantid.simpleapi import (CreateSampleWorkspace, CreateWorkspace, DirectILLCollectData, DirectILLReduction,
+                              LoadILLTOF)
 import numpy
 import numpy.testing
 import testhelpers
@@ -247,6 +248,27 @@ class DirectTest(unittest.TestCase):
         self.assertEquals(axes.get_xscale(), 'log')
         self.assertEquals(axes.get_yscale(), 'log')
 
+    def test_plotconstE_and_plotconstQ_plot_equal_value_at_crossing(self):
+        DirectILLCollectData(
+            Run='ILL/IN4/084447',
+            OutputWorkspace='sample',
+            IncidentEnergyCalibration='Energy Calibration OFF',
+            FlatBkg='Flat Bkg OFF',
+        )
+        DirectILLReduction(
+            InputWorkspace='sample',
+            OutputWorkspace='reduced'
+        )
+        Q = 2.5
+        figure, axes, cuts = directtools.plotconstQ('reduced', Q, 0.01)
+        lineDataQ = axes.get_lines()[0].get_data()
+        E = 2.2
+        figure, axes, cuts = directtools.plotconstE('reduced', E, 0.01)
+        lineDataE = axes.get_lines()[0].get_data()
+        indexE = numpy.argmin(numpy.abs(lineDataQ[0] - E))
+        indexQ = numpy.argmin(numpy.abs(lineDataE[0] - Q))
+        self.assertEquals(lineDataQ[1][indexE], lineDataE[1][indexQ])
+
     def test_plotcuts_keepCutWorkspaces(self):
         ws = LoadILLTOF('ILL/IN4/084446.nxs', StoreInADS=False)
         kwargs = {
-- 
GitLab