From 32c859562c796ecc525d636f66fa7f1e4d9c069d Mon Sep 17 00:00:00 2001 From: Raquel Alvarez Banos Date: Thu, 15 Jan 2015 08:43:12 +0000 Subject: [PATCH] Re #10499 Updating unit test and documentation --- .../Framework/Algorithms/test/RRFMuonTest.h | 22 +++++++++---------- .../docs/source/algorithms/RRFMuon-v1.rst | 15 ++++++------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Code/Mantid/Framework/Algorithms/test/RRFMuonTest.h b/Code/Mantid/Framework/Algorithms/test/RRFMuonTest.h index 411763b2a98f..56694d3e9816 100644 --- a/Code/Mantid/Framework/Algorithms/test/RRFMuonTest.h +++ b/Code/Mantid/Framework/Algorithms/test/RRFMuonTest.h @@ -72,7 +72,7 @@ class RRFMuonTest : public CxxTest::TestSuite // Set Values TS_ASSERT_THROWS_NOTHING( rrfMuon.setProperty("InputWorkspace", ws) ); TS_ASSERT_THROWS_NOTHING( rrfMuon.setProperty("OutputWorkspace", "outputWs") ); - TS_ASSERT_THROWS_NOTHING( rrfMuon.setProperty("Frequency", "197") ); + TS_ASSERT_THROWS_NOTHING( rrfMuon.setProperty("Frequency", "1") ); TS_ASSERT_THROWS_NOTHING( rrfMuon.setProperty("Phase", "0") ); // Execute TS_ASSERT_THROWS_NOTHING(rrfMuon.execute()); @@ -90,12 +90,12 @@ class RRFMuonTest : public CxxTest::TestSuite // The input frequency is close to the precession frequency, so: // The real part of the RRF polarization should be close to 1 for all X values // The imaginary part should be close to 0 for all X values - TS_ASSERT_DELTA( ows->readY(0)[ 0], 1, 0.001 ); - TS_ASSERT_DELTA( ows->readY(0)[49], 1, 0.001 ); - TS_ASSERT_DELTA( ows->readY(0)[99], 1, 0.001 ); - TS_ASSERT_DELTA( ows->readY(1)[ 0], 0, 0.001 ); - TS_ASSERT_DELTA( ows->readY(1)[49], 0, 0.001 ); - TS_ASSERT_DELTA( ows->readY(1)[99], 0, 0.001 ); + TS_ASSERT_DELTA( ows->readY(0)[ 0], 1, 0.001 ); + TS_ASSERT_DELTA( ows->readY(0)[100], 1, 0.001 ); + TS_ASSERT_DELTA( ows->readY(0)[200], 1, 0.001 ); + TS_ASSERT_DELTA( ows->readY(1)[ 0], 0, 0.001 ); + TS_ASSERT_DELTA( ows->readY(1)[100], 0, 0.001 ); + TS_ASSERT_DELTA( ows->readY(1)[200], 0, 0.001 ); } private: @@ -103,17 +103,17 @@ class RRFMuonTest : public CxxTest::TestSuite MatrixWorkspace_sptr createDummyWorkspace() { - int nBins = 100; + int nBins = 300; double pi = 3.14159; MatrixWorkspace_sptr ws = WorkspaceFactory::Instance().create("Workspace2D", 2, nBins+1, nBins); for (int i=0; i(nBins); ws->dataX(0)[i] = x; - ws->dataY(0)[i] = cos(-2*pi*3*x); + ws->dataY(0)[i] = cos(2*pi*x); ws->dataX(1)[i] = x; - ws->dataY(1)[i] = sin(-2*pi*3*x); + ws->dataY(1)[i] = sin(2*pi*x); } ws->dataX(0)[nBins] = nBins; diff --git a/Code/Mantid/docs/source/algorithms/RRFMuon-v1.rst b/Code/Mantid/docs/source/algorithms/RRFMuon-v1.rst index 0a601b1b5a97..e17d81cc6697 100644 --- a/Code/Mantid/docs/source/algorithms/RRFMuon-v1.rst +++ b/Code/Mantid/docs/source/algorithms/RRFMuon-v1.rst @@ -28,23 +28,22 @@ Usage import math # Create an input workspace with two spectra - datax = [(i-50)/100. for i in range(1,100)] - datay1 = [ math.cos(2*3.14159*3*(50-i)/100.) for i in range(1,99) ] - datay2 = [ math.sin(2*3.14159*3*(50-i)/100.) for i in range(1,99) ] + datax = [i/100. for i in range(1,300)] + datay1 = [ math.cos(2*3.14159*i/100.) for i in range(1,299) ] + datay2 = [ math.sin(2*3.14159*i/100.) for i in range(1,299) ] datay = datay1 + datay2 input = CreateWorkspace(dataX=datax, dataY=datay,Nspec=2) # Compute polarization in RRF - output = RRFMuon(input,196,0) - # Print some values - print output.readY(0)[49] - print output.readY(1)[49] + output = RRFMuon(input,1.0,0) + print("%.1f" % output.readY(0)[0]) + print("%.1f" % output.readY(1)[0]) Output: .. testoutput:: ExRRF 1.0 - 0.0 + -0.0 .. categories:: \ No newline at end of file