Skip to content

Commit

Permalink
Refs #10450. Enable unit test to test numerical operation.
Browse files Browse the repository at this point in the history
On the TimeSeriesProperty such as min, max, avarage and etc.

On branch feature/10450_record_order_by_runnumber

	modified:   ../Mantid/Framework/PythonInterface/test/python/plugins/algorithms/ExportExperimentLogTest.py
  • Loading branch information
wdzhou committed Nov 6, 2014
1 parent ae98184 commit 6fd6b26
Showing 1 changed file with 20 additions and 5 deletions.
Expand Up @@ -20,10 +20,10 @@ def test_exportFileNew(self):
# Test algorithm
alg_test = run_algorithm("ExportExperimentLog",
InputWorkspace = "TestMatrixWS",
OutputFilename = "TestRecord.txt",
SampleLogNames = ["run_number", "duration", "proton_charge"],
SampleLogTitles = ["RUN", "Duration", "ProtonCharge"],
SampleLogOperation = [None, None, "sum"],
OutputFilename = "TestRecord001.txt",
SampleLogNames = ["run_number", "duration", "proton_charge", "proton_charge", "proton_charge"],
SampleLogTitles = ["RUN", "Duration", "ProtonCharge", "MinPCharge", "MeanPCharge"],
SampleLogOperation = [None, None, "sum", "min", "average"],
FileMode = "new")

# Validate
Expand Down Expand Up @@ -51,7 +51,22 @@ def test_exportFileNew(self):
# Check line
firstdataline = lines[1]
terms = firstdataline.strip().split("\t")
self.assertEquals(len(terms), 3)
self.assertEquals(len(terms), 5)

# Get property
pchargelog = ws.getRun().getProperty("proton_charge").value
sumpcharge = numpy.sum(pchargelog)
minpcharge = numpy.min(pchargelog)
avgpcharge = numpy.average(pchargelog)

v2 = float(terms[2])
self.assertAlmostEqual(sumpcharge, v2)
v3 = float(terms[3])
self.assertAlmostEqual(minpcharge, v3)
v4 = float(terms[4])
self.assertAlmostEqual(avgpcharge, v4)



#
# # Remove generated files
Expand Down

0 comments on commit 6fd6b26

Please sign in to comment.