Skip to content

Commit

Permalink
Re #10499 Updating unit test and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
raquelalvarezbanos committed Jan 15, 2015
1 parent ce3bd2c commit 32c8595
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
22 changes: 11 additions & 11 deletions Code/Mantid/Framework/Algorithms/test/RRFMuonTest.h
Expand Up @@ -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());
Expand All @@ -90,30 +90,30 @@ 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:
RRFMuon rrfMuon;

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; i++)
{
double x = (i-50.)/nBins;
double x = i/static_cast<int>(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;
Expand Down
15 changes: 7 additions & 8 deletions Code/Mantid/docs/source/algorithms/RRFMuon-v1.rst
Expand Up @@ -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::

0 comments on commit 32c8595

Please sign in to comment.