Commit 8a1588ae authored by Samuel Jackson's avatar Samuel Jackson
Browse files

Refs #18920 Fix bug in Peak

The detPos was not being cleared properly when setting QLab.
parent 86a8b8cb
......@@ -531,6 +531,7 @@ void Peak::setQLabFrame(const Mantid::Kernel::V3D &QLabFrame,
boost::optional<double> detectorDistance) {
// Clear out the detector = we can't know them
m_detectorID = -1;
detPos = V3D();
m_det = IDetector_sptr();
m_row = -1;
m_col = -1;
......
......@@ -264,6 +264,18 @@ public:
TS_ASSERT_EQUALS(qLab, qSampleRotated);
}
void test_getQLabFrame() {
Instrument_sptr inst =
ComponentCreationHelper::createTestInstrumentRectangular2(1, 10);
Peak p(inst, 0, 1.5);
p.setQLabFrame(V3D(1, 1, 1));
auto q = p.getQLabFrame();
// should be the same
TS_ASSERT_DELTA(q[0], 1, 1e-5);
TS_ASSERT_DELTA(q[1], 1, 1e-5);
TS_ASSERT_DELTA(q[2], 1, 1e-5);
}
//------------------------------------------------------------------------------------
/** Can't have Q = 0,0,0 or 0 in the Z direction when creating */
void test_setQLabFrame_ThrowsIfQIsNull() {
......
......@@ -70,9 +70,10 @@ class IPeaksWorkspaceTest(unittest.TestCase):
p.setQLabFrame(V3D(1,1,1))
except Exception:
self.fail("Tried setQLabFrame with one V3D argument")
self.assertAlmostEquals( p.getQLabFrame().X(), -1.4976057446828845, places=10)
self.assertAlmostEquals( p.getQLabFrame().Y(), 0.059904229787315376, places=10)
self.assertAlmostEquals( p.getQLabFrame().Z(), 1.4400957702126842, places=10)
self.assertAlmostEquals( p.getQLabFrame().X(), 1.0, places=10)
self.assertAlmostEquals( p.getQLabFrame().Y(), 1.0, places=10)
self.assertAlmostEquals( p.getQLabFrame().Z(), 1.0, places=10)
try:
p.setQLabFrame(V3D(1,1,1), 1)
......@@ -85,13 +86,15 @@ class IPeaksWorkspaceTest(unittest.TestCase):
def test_peak_setQSampleFrame(self):
pws = WorkspaceCreationHelper.createPeaksWorkspace(1, True)
p = pws.getPeak(0)
try:
p.setQSampleFrame(V3D(1,1,1))
except Exception:
self.fail("Tried setQSampleFrame with one V3D argument")
self.assertAlmostEquals( p.getQSampleFrame().X(), -1.4976057446828845, places=10)
self.assertAlmostEquals( p.getQSampleFrame().Y(), 0.059904229787315376, places=10)
self.assertAlmostEquals( p.getQSampleFrame().Z(), 1.4400957702126842, places=10)
self.assertAlmostEquals( p.getQSampleFrame().X(), 1.0, places=10)
self.assertAlmostEquals( p.getQSampleFrame().Y(), 1.0, places=10)
self.assertAlmostEquals( p.getQSampleFrame().Z(), 1.0, places=10)
try:
p.setQSampleFrame(V3D(1,1,1), 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment