Skip to content
Snippets Groups Projects
Commit bbde4eab authored by Nick Draper's avatar Nick Draper
Browse files

doctest updates commit 1

re #20869
parent 21bccfe6
No related branches found
No related tags found
No related merge requests found
Showing
with 95 additions and 95 deletions
......@@ -35,24 +35,24 @@ Usage
# Load data
ws=Load(Filename='TOFTOFTestdata.nxs')
print "Input workspace"
print "Total number of time channels: ", len(ws.readX(0))
print "Number of filled time channels: ", ws.getRun().getLogData('full_channels').value
print("Input workspace")
print("Total number of time channels: {}".format(len(ws.readX(0))))
print ("Number of filled time channels: {}".format(ws.getRun().getLogData('full_channels').value))
wscropped = TOFTOFCropWorkspace(ws)
print "Output workspace"
print "Total number of time channels: ", len(wscropped.readX(0))
print("Output workspace")
print("Total number of time channels: {}".format(len(wscropped.readX(0))))
Output:
.. testoutput:: ExTOFTOFCropWorkspace
Input workspace
Total number of time channels: 1025
Number of filled time channels: 1020.0
Total number of time channels: 1025
Number of filled time channels: 1020.0
Output workspace
Total number of time channels: 1020
Total number of time channels: 1020
.. categories::
......
......@@ -64,58 +64,58 @@ Usage
ws3 = TOFTOFMergeRuns('ws1,ws2')
# Temperature
print "Temperature of experiment for 1st workspace (in K): ", ws1.getRun().getLogData('temperature').value
print "Temperature of experiment for 2nd workspace (in K): ", ws2.getRun().getLogData('temperature').value
print "Temperature of experiment for merged workspaces = average over workspaces (in K): ", ws3.getRun().getLogData('temperature').value
print("Temperature of experiment for 1st workspace (in K): {}".format(ws1.getRun().getLogData('temperature').value))
print("Temperature of experiment for 2nd workspace (in K): {}".format(ws2.getRun().getLogData('temperature').value))
print("Temperature of experiment for merged workspaces = average over workspaces (in K): {}".format( ws3.getRun().getLogData('temperature').value))
# Duration
print "Duration of experiment for 1st workspace (in s): ", ws1.getRun().getLogData('duration').value
print "Duration of experiment for 2nd workspace (in s): ", ws2.getRun().getLogData('duration').value
print "Duration of experiment for merged workspaces = sum of all durations (in s): ", ws3.getRun().getLogData('duration').value
print("Duration of experiment for 1st workspace (in s): {}".format(ws1.getRun().getLogData('duration').value))
print("Duration of experiment for 2nd workspace (in s): {}".format(ws2.getRun().getLogData('duration').value))
print("Duration of experiment for merged workspaces = sum of all durations (in s): {}".format(ws3.getRun().getLogData('duration').value))
# Run start
print "Start of experiment for 1st workspace: ", ws1.getRun().getLogData('run_start').value
print "Start of experiment for 2nd workspace: ", ws2.getRun().getLogData('run_start').value
print "Start of experiment for merged workspaces = miminum of all workspaces: ", ws3.getRun().getLogData('run_start').value
print("Start of experiment for 1st workspace: {}".format(ws1.getRun().getLogData('run_start').value))
print("Start of experiment for 2nd workspace: {}".format(ws2.getRun().getLogData('run_start').value))
print("Start of experiment for merged workspaces = miminum of all workspaces: {}".format(ws3.getRun().getLogData('run_start').value))
# Run end
print "End of experiment for 1st workspace: ", ws1.getRun().getLogData('run_end').value
print "End of experiment for 2nd workspace: ", ws2.getRun().getLogData('run_end').value
print "End of experiment for merged workspaces = maximum of all workspaces: ", ws3.getRun().getLogData('run_end').value
print("End of experiment for 1st workspace: {}".format(ws1.getRun().getLogData('run_end').value))
print("End of experiment for 2nd workspace: {}".format(ws2.getRun().getLogData('run_end').value))
print("End of experiment for merged workspaces = maximum of all workspaces: {}".format(ws3.getRun().getLogData('run_end').value))
# Run number
print "Run number for 1st workspace: ", ws1.getRun().getLogData('run_number').value
print "Run number for 2nd workspace: ", ws2.getRun().getLogData('run_number').value
print "Run number for merged workspaces = list of all workspaces: ", ws3.getRun().getLogData('run_number').value
print("Run number for 1st workspace: {}".format(ws1.getRun().getLogData('run_number').value))
print("Run number for 2nd workspace: {}".format(ws2.getRun().getLogData('run_number').value))
print("Run number for merged workspaces = list of all workspaces: {}".format(ws3.getRun().getLogData('run_number').value))
# Monitor counts
print "Monitor counts for 1st workspace: ", ws1.getRun().getLogData('monitor_counts').value
print "Monitor counts for 2nd workspace: ", ws2.getRun().getLogData('monitor_counts').value
print "Monitor counts for merged workspaces = sum over all workspaces: ", ws3.getRun().getLogData('monitor_counts').value
print("Monitor counts for 1st workspace: {}".format(ws1.getRun().getLogData('monitor_counts').value))
print("Monitor counts for 2nd workspace: {}".format(ws2.getRun().getLogData('monitor_counts').value))
print("Monitor counts for merged workspaces = sum over all workspaces: {}".format(ws3.getRun().getLogData('monitor_counts').value))
Output:
.. testoutput:: ExTOFTOFMergeRuns2ws
Temperature of experiment for 1st workspace (in K): 294.14
Temperature of experiment for 2nd workspace (in K): 296.16
Temperature of experiment for merged workspaces = average over workspaces (in K): 295.15
Duration of experiment for 1st workspace (in s): 3601
Duration of experiment for 2nd workspace (in s): 3601
Duration of experiment for merged workspaces = sum of all durations (in s): 7202
Start of experiment for 1st workspace: 2013-07-28T10:32:19+0053
Start of experiment for 2nd workspace: 2013-07-28T11:32:19+0053
Start of experiment for merged workspaces = miminum of all workspaces: 2013-07-28T10:32:19+0053
End of experiment for 1st workspace: 2013-07-28T11:32:20+0053
End of experiment for 2nd workspace: 2013-07-28T12:32:19+0053
End of experiment for merged workspaces = maximum of all workspaces: 2013-07-28T12:32:19+0053
Run number for 1st workspace: TOFTOFTestdata
Run number for 2nd workspace: TOFTOFTestdata2
Run number for merged workspaces = list of all workspaces: ['TOFTOFTestdata', 'TOFTOFTestdata2']
Monitor counts for 1st workspace: 136935
Monitor counts for 2nd workspace: 145145
Monitor counts for merged workspaces = sum over all workspaces: 282080
Temperature of experiment for 1st workspace (in K): 294.14
Temperature of experiment for 2nd workspace (in K): 296.16
Temperature of experiment for merged workspaces = average over workspaces (in K): 295.15
Duration of experiment for 1st workspace (in s): 3601
Duration of experiment for 2nd workspace (in s): 3601
Duration of experiment for merged workspaces = sum of all durations (in s): 7202
Start of experiment for 1st workspace: 2013-07-28T10:32:19+0053
Start of experiment for 2nd workspace: 2013-07-28T11:32:19+0053
Start of experiment for merged workspaces = miminum of all workspaces: 2013-07-28T10:32:19+0053
End of experiment for 1st workspace: 2013-07-28T11:32:20+0053
End of experiment for 2nd workspace: 2013-07-28T12:32:19+0053
End of experiment for merged workspaces = maximum of all workspaces: 2013-07-28T12:32:19+0053
Run number for 1st workspace: TOFTOFTestdata
Run number for 2nd workspace: TOFTOFTestdata2
Run number for merged workspaces = list of all workspaces: ['TOFTOFTestdata', 'TOFTOFTestdata2']
Monitor counts for 1st workspace: 136935
Monitor counts for 2nd workspace: 145145
Monitor counts for merged workspaces = sum over all workspaces: 282080
**Example - Merge group of workspaces**
......@@ -132,17 +132,17 @@ Output:
group=GroupWorkspaces('ws1,ws2')
groupmerged=TOFTOFMergeRuns(group)
print "Monitor counts for 1st workspace: ", ws1.getRun().getLogData('monitor_counts').value
print "Monitor counts for 2nd workspace: ", ws2.getRun().getLogData('monitor_counts').value
print "Monitor counts for merged workspaces = sum over all workspaces: ", groupmerged.getRun().getLogData('monitor_counts').value
print("Monitor counts for 1st workspace: {}".format(ws1.getRun().getLogData('monitor_counts').value))
print("Monitor counts for 2nd workspace: {}".format(ws2.getRun().getLogData('monitor_counts').value))
print("Monitor counts for merged workspaces = sum over all workspaces: {}".format(groupmerged.getRun().getLogData('monitor_counts').value))
Output:
.. testoutput:: ExTOFTOFMergeRunsGroup
Monitor counts for 1st workspace: 136935
Monitor counts for 2nd workspace: 145145
Monitor counts for merged workspaces = sum over all workspaces: 282080
Monitor counts for 1st workspace: 136935
Monitor counts for 2nd workspace: 145145
Monitor counts for merged workspaces = sum over all workspaces: 282080
.. categories::
......
......@@ -71,7 +71,7 @@ Usage
corrected_reduction, peak_position, scale_factor_1, scale_factor_2 = \
TOSCABankCorrection(InputWorkspace=original_reduction)
print 'Target peak centre: %.f' % peak_position
print('Target peak centre: %.f' % peak_position)
Output:
......@@ -89,7 +89,7 @@ Output:
TOSCABankCorrection(InputWorkspace=original_reduction,
PeakPosition='715')
print 'Target peak centre: %.f' % peak_position
print( )'Target peak centre: %.f' % peak_position)
Output:
......
......@@ -30,13 +30,13 @@ Usage
ws=LoadIsawPeaks("TOPAZ_3007.peaks")
FindUBUsingFFT(ws,MinD=8.0,MaxD=13.0)
print "Before Transformation:"
print ws.sample().getOrientedLattice().getUB()
print("Before Transformation:")
print(ws.sample().getOrientedLattice().getUB())
#This HKLTransform is a matrix that will swap H and K and negate L
TransformHKL(ws,HKLTransform="0,1,0,1,0,0,0,0,-1")
print "\nAfter Transformation:"
print ws.sample().getOrientedLattice().getUB()
print("\nAfter Transformation:")
print(ws.sample().getOrientedLattice().getUB())
Output:
......
......@@ -104,8 +104,8 @@ Usage
EnergyMax=0.5,
BinReductionFactor=10)
print 'Number of output bins: %d' % (params.cell('SampleOutputBins', 0))
print 'Resolution bins: %d' % (params.cell('ResolutionBins', 0))
print('Number of output bins: %d' % (params.cell('SampleOutputBins', 0)))
print('Resolution bins: %d' % (params.cell('ResolutionBins', 0)))
Output:
......
......@@ -33,16 +33,16 @@ Usage
# Create a workspace with 2 banks and 4 pixels per bank (8 spectra)
# and X axis with 100 bins
ws = CreateSampleWorkspace(BankPixelWidth=2)
print "Rank before = (", ws.getNumberHistograms(), ",", ws.blocksize(), ")"
print("Rank before = ( {0}, {1} )".format(ws.getNumberHistograms(),ws.blocksize()))
ws = Transpose(ws)
print "Rank after = (", ws.getNumberHistograms(), ",", ws.blocksize(), ")"
print("Rank after = ( {0}, {1} )".format(ws.getNumberHistograms(),ws.blocksize()))
Output:
.. testoutput:: Ex
Rank before = ( 8 , 100 )
Rank after = ( 100 , 8 )
Rank before = ( 8, 100 )
Rank after = ( 100, 8 )
.. categories::
......
......@@ -21,16 +21,16 @@ Usage
def print_dims(ws):
for i in range(ws.getNumDims()):
print 'Dimension %i is %s' % (i, ws.getDimension(i).name)
print('Dimension %i is %s' % (i, ws.getDimension(i).name))
mdws = CreateMDWorkspace(Dimensions=3, Extents='-10,10,-10,10,-10,10', Names='A,B,C', Units='U,U,U')
FakeMDEventData(InputWorkspace=mdws, PeakParams='500000,0,0,0,3')
binned = BinMD(InputWorkspace=mdws, AlignedDim0='A,0,10,100', AlignedDim1='B,-10,10,100', AlignedDim2='C,-10,10,1')
print 'Dimensions before', binned.getNumDims()
print('Dimensions before {}'.format(binned.getNumDims()))
print_dims(binned)
# Transpose the workspace
transposed = TransposeMD(binned, Axes=[1,0])
print 'Dimensions after', transposed.getNumDims()
print('Dimensions after {}'.format(transposed.getNumDims()))
print_dims(transposed)
Output:
......
......@@ -100,7 +100,7 @@ Usage
# To access individual outputs use result[i] where i is the index of the required output.
result = UnwrapMonitor(InputWorkspace=ws,LRef=11)
print "JoinWaveLength is: " + str(result[1])
print("JoinWaveLength is: " + str(result[1]))
Output:
......
......@@ -54,8 +54,8 @@ Usage
ws = CreateSampleWorkspace("Event",NumBanks=1,BankPixelWidth=1)
wsOut = UnwrapSNS(ws,LRef=10)
print "Input", ws.readY(0)[ws.blocksize()-1]
print "Output", wsOut.readY(0)[wsOut.blocksize()-1]
print("Input {}".format(ws.readY(0)[ws.blocksize()-1]))
print("Output {}".format(wsOut.readY(0)[wsOut.blocksize()-1]))
Output:
......
......@@ -82,7 +82,7 @@ Usage
''' print first 10 detectors from given instrument '''
# get first 10 detectors using detector ID
print "{0} {1} instrument".format(instr_type, instr.getName())
print("{0} {1} instrument".format(instr_type, instr.getName()))
for i in xrange(0,10):
if i<3:
detBase = 1
......@@ -91,8 +91,8 @@ Usage
detID = detBase+i
det1 = instr.getDetector(detID);
pos = det1.getPos();
print 'det with ID: {0:5} is monitor? {1:5}, polar angle: {2:10.3f}, position: | {3:<10.3f} | {4:<10.3f} | {5:<10.3f}|\n'.format(\
detID,det1.isMonitor(),(det1.getPhi()*(180/math.pi)),pos.X(),pos.Y(),pos.Z()),
print('det with ID: {0:5} is monitor? {1:5}, polar angle: {2:10.3f}, position: | {3:<10.3f} | {4:<10.3f} | {5:<10.3f}|'.format(\
detID,det1.isMonitor(),(det1.getPhi()*(180/math.pi)),pos.X(),pos.Y(),pos.Z()))
print '*********************************************************************************'
#--------------------------------------------------------------------------------------
......
......@@ -64,11 +64,11 @@ Usage
tablews.addRow(["A", 1.34])
tablews.addRow(["B", 2.34])
print "Value before %.2f" % tablews.cell(0, 1)
print("Value before %.2f" % tablews.cell(0, 1))
UpdatePeakParameterTableValue(tablews, Column="Value", ParameterNames=["A"], NewFloatValue=1.00)
print "Value after %.2f" % tablews.cell(0, 1)
print("Value after %.2f" % tablews.cell(0, 1))
Output:
......
......@@ -57,9 +57,9 @@ Usage
corrected, background = VesuvioCalculateGammaBackground(tof_ws, ComptonFunction=mass_function,
WorkspaceIndexList=0)
print "First 5 values of input:", tof_ws.readY(0)[0:4]
print "First 5 values of background:", background.readY(0)[0:4]
print "First 5 values of corrected:", corrected.readY(0)[0:4]
print("First 5 values of input: {}".format(tof_ws.readY(0)[0:4]))
print("First 5 values of background: {}".format(background.readY(0)[0:4]))
print("First 5 values of corrected: {}".format(corrected.readY(0)[0:4]))
Output:
......@@ -89,8 +89,8 @@ Output:
mass_function = "name=GaussianComptonProfile,Mass=1.0079,Width=0.4,Intensity=1.1"
corrected, background = VesuvioCalculateGammaBackground(tof_ws, ComptonFunction=mass_function)
print "Number of background spectra:", background.getNumberHistograms()
print "Number of corrected spectra:", corrected.getNumberHistograms()
print("Number of background spectra: {}".format(background.getNumberHistograms()))
print("Number of corrected spectra: {}".format(corrected.getNumberHistograms()))
Output:
......
......@@ -38,9 +38,9 @@ Usage
ws = mtd['DiffractionReductions'].getItem(0)
print 'Workspace name: %s' % ws.name()
print 'Number of spectra: %d' % ws.getNumberHistograms()
print 'Number of bins: %s' % ws.blocksize()
print('Workspace name: %s' % ws.name())
print('Number of spectra: %d' % ws.getNumberHistograms())
print('Number of bins: %s' % ws.blocksize())
Output:
......
......@@ -27,10 +27,10 @@ Usage
resolution, l1_dist, theta_dist = VesuvioL1ThetaResolution(NumEvents=1000)
resolution_spec_names = resolution.getAxis(1).extractValues()
print "Resolution spectra: %s" % (', '.join(resolution_spec_names))
print("Resolution spectra: %s" % (', '.join(resolution_spec_names)))
print "L1 distribution spectra count: %d" % (l1_dist.getNumberHistograms())
print "Theta distribution spectra count: %d" % (theta_dist.getNumberHistograms())
print("L1 distribution spectra count: %d" % (l1_dist.getNumberHistograms()))
print("Theta distribution spectra count: %d" % (theta_dist.getNumberHistograms()))
Output:
......
......@@ -34,7 +34,7 @@ Usage
tof, ysp = VesuvioResolution(Workspace=tof_ws, Mass=1.0079)
print 'Resolution in %s and %s.' % (tof.getAxis(0).getUnit().symbol(), ysp.getAxis(0).getUnit().symbol())
print('Resolution in %s and %s.' % (tof.getAxis(0).getUnit().symbol(), ysp.getAxis(0).getUnit().symbol()))
Output:
......
......@@ -30,8 +30,8 @@ Usage
dens_tbl, trans_tbl = VesuvioThickness(masses, amplitudes, trans_guess, thickness, number_density)
# Test output
print "The final density is: %.4f" % dens_tbl.cell(9,1)
print "The final transmission is: %.4f" % trans_tbl.cell(9,1)
print("The final density is: %.4f" % dens_tbl.cell(9,1))
print("The final transmission is: %.4f" % trans_tbl.cell(9,1))
Output:
......
......@@ -41,9 +41,9 @@ The following code loads a BOA file and prints out information about the wavelen
lamdba_distribution = mtd['histogram61'].readY(0)
lambda_values = mtd['histogram61'].readX(0)
print "The wavelength spectrum is described by", len(lamdba_distribution),"points."
print "The range covered is", round(lambda_values[0], 4), "-", round(lambda_values[-1], 4), "Angstrom."
print "The maximum is located at", round(lambda_values[np.argmax(lamdba_distribution)], 4), "Angstrom."
print("The wavelength spectrum is described by {}".format(len(lamdba_distribution),"points."))
print("The range covered is {0} - {1} Angstrom.".format(round(lambda_values[0], 4),round(lambda_values[-1], 4)))
print("The maximum is located at {} Angstrom.".format(round(lambda_values[np.argmax(lamdba_distribution)], 4)))
This script leads to the following output:
......
......@@ -33,9 +33,9 @@ Usage
# perform the algorithm
ws = WeightedMean(ws1, ws2)
print "The X values are: " + str(ws.readX(0))
print "The Y values are: " + str(ws.readY(0))
print "The E values are: " + str(ws.readE(0))
print("The X values are: " + str(ws.readX(0)))
print("The Y values are: " + str(ws.readY(0)))
print("The E values are: " + str(ws.readE(0)))
Output:
......
......@@ -30,8 +30,8 @@ Usage
dataE = range(1,12)
ws = CreateWorkspace(dataX, dataY, dataE)
ws1 = WeightedMeanOfWorkspace(ws)
print "Weighted Mean of Workspace:", str(ws1.readY(0))
print "Weighted Mean Error of Workspace:", str(ws1.readE(0))
print("Weighted Mean of Workspace: {}".format(str(ws1.readY(0))))
print("Weighted Mean Error of Workspace: {}".format(str(ws1.readE(0))))
Output:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment