Skip to content

Commit

Permalink
Implemented unit test of CreateLeBailFitInput. Refs #6862.
Browse files Browse the repository at this point in the history
1. Added the unit test files
2. Added 2 files for unit test to AutoTestData
  • Loading branch information
wdzhou committed Aug 12, 2013
1 parent 77ffb44 commit 328c5b7
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
set ( TEST_PY_FILES
CheckForSampleLogsTest.py
ConjoinSpectraTest.py
CreateLeBailFitInputTest.py
CreateWorkspaceTest.py
DakotaChiSquaredTest.py
FindReflectometryLinesTest.py
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import unittest
import numpy
from mantid.kernel import *
from mantid.api import *
from testhelpers import run_algorithm
from mantid.api import AnalysisDataService

import os

class CreateLeBailFitInputTest(unittest.TestCase):

def test_LoadHKLFile(self):
""" Test to load a .hkl file
"""
# Set up
alg_test = run_algorithm("CreateLeBailFitInput",
Instrument = "POWGEN",
ReflectionsFile = "LB4853b2.hkl",
FullprofParameterFile = "2011B_HR60b2.irf",
Bank = 2,
LatticeConstant = 4.66,
InstrumentParameterWorkspace = "PG3_Bank2_Foo",
BraggPeakParameterWorkspace = "LaB6_Peaks"
)

# Execute
self.assertTrue(alg_test.isExecuted())

# Verify some values
# Profile parameter workspace
paramws = AnalysisDataService.retrieve("PG3_Bank2_Foo")
self.assertEqual(27, paramws.rowCount())

paramnames = []
for i in xrange(27):
paramname = paramws.cell(i, 0)
paramnames.append(paramname)
self.assertEqual(paramnames.count("LatticeConstant"), 1)


# Bragg peak list
braggws = AnalysisDataService.retrieve("LaB6_Peaks")
self.assertEqual(145, braggws.rowCount())

# 4. Delete the test hkl file
AnalysisDataService.remove("PG3_Bank2_Foo")
AnalysisDataService.remove("LaB6_Peaks")

return

if __name__ == '__main__':
unittest.main()
20 changes: 20 additions & 0 deletions Test/AutoTestData/2011B_HR60b2.irf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
! ---------------------------------------------- Bank 2 CWL = 1.0660A
! Type of profile function: back-to-back exponentials * pseudo-Voigt
NPROF 10
! Tof-min(us) step Tof-max(us)
TOFRG 6286.6573 5.0000 70140.0000
! Zero Dtt1
ZD2TOF 0.00 22777.7440
! Zerot Dtt1t Dtt2t x-cross Width
ZD2TOT 61.40 22764.803 0.30 0.3560 1.6368
! TOF-TWOTH of the bank
TWOTH 90.807
! Sig-2 Sig-1 Sig-0
SIGMA 185.900 10.000 0.000
! Gam-2 Gam-1 Gam-0
GAMMA 0.000 0.000 0.000
! alph0 beta0 alph1 beta1
ALFBE 1.677 6.276 4.633 4.094
! alph0t beta0t alph1t beta1t
ALFBT 40.480 84.073 0.000 2.737
END

0 comments on commit 328c5b7

Please sign in to comment.