diff --git a/docs/source/algorithms/RemoveBackground-v1.rst b/docs/source/algorithms/RemoveBackground-v1.rst index bcd8ae6fed9a387aea621d61b3205c1650886073..87dd338d4d989631b31abb37a640ef084cd658c0 100644 --- a/docs/source/algorithms/RemoveBackground-v1.rst +++ b/docs/source/algorithms/RemoveBackground-v1.rst @@ -60,13 +60,13 @@ Proof of concept background removal algorithm:: wsParent = mtd[groupedFilename]; nHist = wsParent.getNumberHistograms(); - print "Parent workspace contains {0:10} histograms".format(nHist) + print("Parent workspace contains {0:10} histograms".format(nHist)) # Get the energy binning correspondent to the binning produced by rebin function (not to re-implement the same function) ws1s = ExtractSingleSpectrum(wsParent,0); ws1s = ConvertUnits(ws1s,'DeltaE','Direct',Ei); ws1s = Rebin(ws1s,Params=[e_min,dE,e_max]); e_bins = ws1s.dataX(0); - nBins =e_bins.size; + nBins = e_bins.size; x=[e_bins[i] for i in xrange(0,nBins)] y=[0 for xx in xrange(0,len(x)-1)]*nHist @@ -102,7 +102,7 @@ Proof of concept background removal algorithm:: eGrid.setE(nspec, error) else: # signal and error for background is 0 anyway. pass - #print " bg at spectra {0} equal to : {1}".format(nspec,bg[0]) + #print(" bg at spectra {0} equal to : {1}".format(nspec,bg[0])) background = eGrid; @@ -206,9 +206,9 @@ Usage ER = Result .dataE(0); # print first spectra, Note invalid error calculations - print "| x sampl | x result | S sample | S no bg | Err samp | Err no_bg|" - for i in xrange(0,20): - print "|{0:10}|{1:10}|{2:10.4f}|{3:10.3f}|{4:10.3f}|{5:10.3f}|".format(XS[i],XR[i],YS[i],YR[i],ES[i],ER[i]); + print("| x sampl | x result | S sample | S no bg | Err samp | Err no_bg|") + for i in range(0,20): + print("|{0:10}|{1:10}|{2:10.4f}|{3:10.3f}|{4:10.3f}|{5:10.3f}|".format(XS[i],XR[i],YS[i],YR[i],ES[i],ER[i])) .. testoutput:: ExFlatBkgRemoval diff --git a/docs/source/algorithms/RemoveBins-v1.rst b/docs/source/algorithms/RemoveBins-v1.rst index 679051664f59c26771fd076b68a81e7fde51e51d..ec8d56cea2f4838ec3b07035a7d201e136bf3b2b 100644 --- a/docs/source/algorithms/RemoveBins-v1.rst +++ b/docs/source/algorithms/RemoveBins-v1.rst @@ -69,8 +69,8 @@ Usage OutputWorkspace = RemoveBins( ws, 20, 35) # Show workspaces - print "Before RemoveBins",ws.readY(0) - print "After RemoveBins",OutputWorkspace.readY(0) + print("Before RemoveBins {}".format(ws.readY(0))) + print("After RemoveBins {}".format(OutputWorkspace.readY(0))) Output: diff --git a/docs/source/algorithms/RemoveExpDecay-v1.rst b/docs/source/algorithms/RemoveExpDecay-v1.rst index cd68f2245c6f9cf6c0d7e483983a3f02e4490d40..97985ff7e3a27d8c79c0676470717b224753fbf6 100644 --- a/docs/source/algorithms/RemoveExpDecay-v1.rst +++ b/docs/source/algorithms/RemoveExpDecay-v1.rst @@ -33,7 +33,7 @@ Usage output = RemoveExpDecay(input) - print "Exp. decay removed:", output.readY(0) + print("Exp. decay removed: {}".format(output.readY(0))) Output: diff --git a/docs/source/algorithms/RemoveLogs-v1.rst b/docs/source/algorithms/RemoveLogs-v1.rst index b2b18296f0c306b6ddf1eb72e3511a255b23d7e9..de038a5308a374a5f19152170e56af453b902470 100644 --- a/docs/source/algorithms/RemoveLogs-v1.rst +++ b/docs/source/algorithms/RemoveLogs-v1.rst @@ -17,15 +17,15 @@ Usage # create some workspace with an instrument ws = CreateSampleWorkspace() - print "Original logs: ", ws.run().keys() + print("Original logs: {}".format(ws.run().keys())) # remove logs, but keep some RemoveLogs(ws,KeepLogs="run_start, run_title") - print "Logs left: ", ws.run().keys() + print("Logs left: {}".format(ws.run().keys())) # delete all logs RemoveLogs(ws) - print "Logs left (should be empty): ", ws.run().keys() + print("Logs left (should be empty): {}".format(ws.run().keys())) .. testcleanup:: RemoveLogs diff --git a/docs/source/algorithms/RemoveMaskedSpectra-v1.rst b/docs/source/algorithms/RemoveMaskedSpectra-v1.rst index 48f66e7e04ddd349be150740cce83bc1c9f7346c..eae7f4c961ca3ad2b743ec7a7d32310dbcb1dd9c 100644 --- a/docs/source/algorithms/RemoveMaskedSpectra-v1.rst +++ b/docs/source/algorithms/RemoveMaskedSpectra-v1.rst @@ -26,11 +26,11 @@ Usage ws = CreateSampleWorkspace() # Mask some detectors MaskDetectors(ws,SpectraList=[10,20,30,40,50]) - print 'Input workspace has %s spectra' % ws.getNumberHistograms() + print('Input workspace has {} spectra'.format(ws.getNumberHistograms())) # Removed the 5 masked spectra removed = RemoveMaskedSpectra(ws) - print 'Output workspace has %s spectra' % removed.getNumberHistograms() + print('Output workspace has {} spectra'.format(removed.getNumberHistograms())) Output: diff --git a/docs/source/algorithms/RemovePromptPulse-v1.rst b/docs/source/algorithms/RemovePromptPulse-v1.rst index 2f4614002a3302c18f37770926700ac8d544f28f..8f41765299f5d1051d215c37f6da139af32b0be2 100644 --- a/docs/source/algorithms/RemovePromptPulse-v1.rst +++ b/docs/source/algorithms/RemovePromptPulse-v1.rst @@ -31,10 +31,10 @@ Usage x=w1.dataX(0) y=w1.dataY(0) - print "Y(",x[100],") = ",y[100] - print "Y(",x[1000],") = ",y[1000] - print "Y(",x[4100],") = ",y[4100] - print "Y(",x[5000],") = ",y[5000] + print("Y( {} ) = {:.1f}".format(x[100], y[100])) + print("Y( {} ) = {:.1f}".format(x[1000], y[1000])) + print("Y( {} ) = {:.1f}".format(x[4100], y[4100])) + print("Y( {} ) = {:.1f}".format(x[5000], y[5000])) .. testcleanup:: RemovePromptPulse diff --git a/docs/source/algorithms/RemoveWorkspaceHistory-v1.rst b/docs/source/algorithms/RemoveWorkspaceHistory-v1.rst index 70ca0d27c83c8f0ac6859c81288492a6dd84cad6..0c29f28a6d7884a1f0b85e035f0124c18790d431 100644 --- a/docs/source/algorithms/RemoveWorkspaceHistory-v1.rst +++ b/docs/source/algorithms/RemoveWorkspaceHistory-v1.rst @@ -21,9 +21,9 @@ Usage def print_workspace_history(ws): history = ws.getHistory() - print "Workspace %s has %i algorithms in it's history" %(ws,history.size()) + print("Workspace {} has {} algorithms in it's history".format(ws,history.size())) for alg in history.getAlgorithmHistories(): - print " " + alg.name() + print(" " + alg.name()) # create histogram workspace ws = CreateSampleWorkspace(NumBanks=1,BankPixelWidth=1) @@ -38,7 +38,7 @@ Usage RemoveWorkspaceHistory(ws) - print "After RemoveWorkspaceHistory" + print("After RemoveWorkspaceHistory") print_workspace_history(ws) diff --git a/docs/source/algorithms/RenameWorkspace-v1.rst b/docs/source/algorithms/RenameWorkspace-v1.rst index 74194096562643cced9bd08637244d99dde5b3d2..0eeb092d51ce407fb223de2bc0527dedb3ac2549 100644 --- a/docs/source/algorithms/RenameWorkspace-v1.rst +++ b/docs/source/algorithms/RenameWorkspace-v1.rst @@ -42,35 +42,35 @@ Usage myWs=CreateSampleWorkspace() mon_ws = CreateSampleWorkspace() myWs.setMonitorWorkspace(mon_ws) - print "*********************************************************************" - print "{0:20}|{1:>20}|{2:>20}|".format("Existing WS names: ",myWs.name(),mon_ws.name()) + print("*********************************************************************") + print("{0:20}|{1:>20}|{2:>20}|".format("Existing WS names: ",myWs.name(),mon_ws.name())) obj_inADS = AnalysisDataService.getObjectNames() obj_inADS.sort() - print "{0:20}|{1:>6}| With Names: |{2:>20}|{3:>20}|".format("Exist in ADS: ",len(obj_inADS),obj_inADS[0],obj_inADS[1]) - # + print("{0:20}|{1:>6}| With Names: |{2:>20}|{3:>20}|".format("Exist in ADS: ",len(obj_inADS),obj_inADS[0],obj_inADS[1])) + NameA = RenameWorkspace(myWs) - # - print "***** After simple rename:" - print "{0:20}|{1:>20}|{2:>20}|".format("Existing WS names: ",NameA.name(),mon_ws.name()) + + print("***** After simple rename:") + print("{0:20}|{1:>20}|{2:>20}|".format("Existing WS names: ",NameA.name(),mon_ws.name())) obj_inADS = AnalysisDataService.getObjectNames() obj_inADS.sort() - print "{0:20}|{1:>6}| With Names: |{2:>20}|{3:>20}|".format("Exist in ADS: ",len(obj_inADS),obj_inADS[0],obj_inADS[1]) + print("{0:20}|{1:>6}| With Names: |{2:>20}|{3:>20}|".format("Exist in ADS: ",len(obj_inADS),obj_inADS[0],obj_inADS[1])) - print "Old pointer to myWs refers to workspace with new name: ",myWs.name() - print "*********************************************************************" - print "***** After renaming workspace and monitors workspace together:" - # + print("Old pointer to myWs refers to workspace with new name: {}".format(myWs.name())) + print("*********************************************************************") + print("***** After renaming workspace and monitors workspace together:") + NameB = RenameWorkspace(myWs,RenameMonitors=True) - # - print "{0:20}|{1:>20}|{2:>20}|".format("Existing WS names: ",NameB.name(),mon_ws.name()) + + print("{0:20}|{1:>20}|{2:>20}|".format("Existing WS names: ",NameB.name(),mon_ws.name())) obj_inADS = AnalysisDataService.getObjectNames() obj_inADS.sort() - print "{0:20}|{1:>6}| With Names: |{2:>20}|{3:>20}|".format("Exist in ADS: ",len(obj_inADS),obj_inADS[0],obj_inADS[1]) - # + print("{0:20}|{1:>6}| With Names: |{2:>20}|{3:>20}|".format("Exist in ADS: ",len(obj_inADS),obj_inADS[0],obj_inADS[1])) + mon_ws1 = NameB.getMonitorWorkspace() - print "The name of the monitor workspace attached to workspace:{0:>6}| Is: {1:>10}|".\ - format(NameB.name(),mon_ws1.name()) - print "*********************************************************************" + print("The name of the monitor workspace attached to workspace:{0:>6}| Is: {1:>10}|". + format(NameB.name(),mon_ws1.name())) + print("*********************************************************************") Output: @@ -104,16 +104,16 @@ Output: CreateWorkspace([0], [0], OutputWorkspace="wsNew") #This will fail telling us that 'wsOld' already exists - print 'Trying to rename with OverwriteExisting set to false.' + print('Trying to rename with OverwriteExisting set to false.') try: RenameWorkspace(InputWorkspace="wsNew", OutputWorkspace="wsOld", OverwriteExisting=False) except RuntimeError: - print 'RuntimeError: The workspace wsOld already exists' + print('RuntimeError: The workspace wsOld already exists') #This will succeed in renaming and 'wsOld' will be replaced with 'wsNew' - print 'Trying to rename with OverwriteExisting set to true.' + print('Trying to rename with OverwriteExisting set to true.') RenameWorkspace(InputWorkspace="wsNew", OutputWorkspace="wsOld", OverwriteExisting=True) - print 'Succeeded' + print('Succeeded') Output: diff --git a/docs/source/algorithms/RenameWorkspaces-v1.rst b/docs/source/algorithms/RenameWorkspaces-v1.rst index 23a970ba89073c195971fe7233a9335c9a365001..002feebc6e77d26f6d9e77eafd8580cefa955555 100644 --- a/docs/source/algorithms/RenameWorkspaces-v1.rst +++ b/docs/source/algorithms/RenameWorkspaces-v1.rst @@ -50,13 +50,13 @@ Usage ws_before_rename = mtd.getObjectNames() ws_before_rename.sort() - print 'Workspaces in the ADS _before_ renaming:', ws_before_rename + print('Workspaces in the ADS _before_ renaming: {}'.format(ws_before_rename)) RenameWorkspaces(names, WorkspaceNames=['new_ws1', 'new_ws2', 'new_ws3']) ws_after_rename = mtd.getObjectNames() ws_after_rename.sort() - print 'Workspaces in the ADS _after_ renaming:', ws_after_rename + print('Workspaces in the ADS _after_ renaming: {}'.format(ws_after_rename)) Output: @@ -80,13 +80,13 @@ Output: ws_before_rename = mtd.getObjectNames() ws_before_rename.sort() - print 'Workspaces in the ADS _before_ renaming:', ws_before_rename + print('Workspaces in the ADS _before_ renaming: {}'.format(ws_before_rename)) RenameWorkspaces(names, Prefix='new_', Suffix='_name') ws_after_rename = mtd.getObjectNames() ws_after_rename.sort() - print 'Workspaces in the ADS _after_ renaming:', ws_after_rename + print('Workspaces in the ADS _after_ renaming: {}'.format(ws_after_rename)) Output: @@ -112,16 +112,16 @@ Output: CreateWorkspace([0], [0], OutputWorkspace=name) #This will fail telling us that 'new_ws1' already exists - print 'Trying to rename with OverwriteExisting set to false.' + print('Trying to rename with OverwriteExisting set to false.') try: RenameWorkspaces(names, Prefix='new_', OverwriteExisting=False) except RuntimeError: - print 'RuntimeError: A workspace called new_ws1 already exists' + print('RuntimeError: A workspace called new_ws1 already exists') #This will succeed in renaming and 'new_ws1' will be replaced with 'ws1' - print 'Trying to rename with OverwriteExisting set to true.' + print('Trying to rename with OverwriteExisting set to true.') RenameWorkspaces(names, Prefix='new_', OverwriteExisting=True) - print 'Succeeded' + print('Succeeded') Output: diff --git a/docs/source/algorithms/ReplaceSpecialValues-v1.rst b/docs/source/algorithms/ReplaceSpecialValues-v1.rst index e521c7077ad1839768837873d16860340d361067..d2015400deaf9e238bb13e902e38210fc6e4ed09 100644 --- a/docs/source/algorithms/ReplaceSpecialValues-v1.rst +++ b/docs/source/algorithms/ReplaceSpecialValues-v1.rst @@ -42,10 +42,10 @@ Usage BigNumberThreshold=1000, BigNumberValue=1000, SmallNumberThreshold=1e-6, SmallNumberValue=200) - print "i\tBefore\tAfter" - print "-\t------\t-----" + print("i\tBefore\tAfter") + print("-\t------\t-----") for i in range(5): - print "%i\t%s\t%s" % (i, yArray[i],ws.readY(0)[i]) + print("{}\t{}\t{}".format(i, yArray[i],ws.readY(0)[i])) Output: @@ -75,7 +75,7 @@ Output: ws = ReplaceSpecialValues(ws, SmallNumberThreshold=1e-6) print("Before\t\t After") - print("{0}\t{1}".format(wsYArray[0], ws.readY(0)[0])) + print("{0:.11e}\t{1:.1f}".format(wsYArray[0], ws.readY(0)[0])) Output: diff --git a/docs/source/algorithms/ReplicateMD-v1.rst b/docs/source/algorithms/ReplicateMD-v1.rst index cb2f2b631b4bf49efb39ed592f6f1baebaec96ad..ff6ac463e020cb8f13e143f22db32cdeafa82714 100644 --- a/docs/source/algorithms/ReplicateMD-v1.rst +++ b/docs/source/algorithms/ReplicateMD-v1.rst @@ -32,8 +32,8 @@ Usage replicated = ReplicateMD(ShapeWorkspace=shape, DataWorkspace=data) - print 'Num dims:', replicated.getNumDims() - print 'Num points:', replicated.getNPoints() + print('Num dims: {}'.format(replicated.getNumDims())) + print('Num points: {}'.format(replicated.getNPoints())) Output: diff --git a/docs/source/algorithms/ResizeRectangularDetector-v1.rst b/docs/source/algorithms/ResizeRectangularDetector-v1.rst index a39b39db74cedc56f3483989c85de87863920d62..6675b26a94256c3ae0b371cc4ad1e7f4565413e7 100644 --- a/docs/source/algorithms/ResizeRectangularDetector-v1.rst +++ b/docs/source/algorithms/ResizeRectangularDetector-v1.rst @@ -50,8 +50,8 @@ Usage bank1=i.getComponentByName('bank1') bank2=i.getComponentByName('bank2') - print ("bank 1 was scaled and is now %.2f by %.2f" % (bank1.xsize(), bank1.ysize())) - print ("bank 2 was not scaled and remains %.2f by %.2f" % (bank2.xsize(), bank2.ysize())) + print ("bank 1 was scaled and is now {:.2f} by {:.2f}".format(bank1.xsize(), bank1.ysize())) + print ("bank 2 was not scaled and remains {:.2f} by {:.2f}".format(bank2.xsize(), bank2.ysize())) Output: diff --git a/docs/source/algorithms/SANSBeamFluxCorrection-v1.rst b/docs/source/algorithms/SANSBeamFluxCorrection-v1.rst index 624821a58da03317cc3659f696f7d0762d91e858..28f5a224afd08f4faa4cbb02e8fa76aec149ab9f 100644 --- a/docs/source/algorithms/SANSBeamFluxCorrection-v1.rst +++ b/docs/source/algorithms/SANSBeamFluxCorrection-v1.rst @@ -43,6 +43,7 @@ Usage print("The expected value of each bin should be {:.11e}.".format(0.1/(49152*0.1)/(49152*0.1))) print("The actual value of the first bin is {:.11e}.".format(corrected[0].readY(0)[0])) + Output: