diff --git a/Code/Mantid/docs/source/algorithms/GeneratePythonScript-v1.rst b/Code/Mantid/docs/source/algorithms/GeneratePythonScript-v1.rst index 639c66ccf6b2..4f64da780ac1 100644 --- a/Code/Mantid/docs/source/algorithms/GeneratePythonScript-v1.rst +++ b/Code/Mantid/docs/source/algorithms/GeneratePythonScript-v1.rst @@ -46,7 +46,7 @@ Output: def removeFiles(files): for ws in files: try: - path = os.path.join(config['defaultsave.directory'], ws) + path = os.path.join(os.path.expanduser("~"), ws) os.remove(path) except: pass @@ -58,15 +58,18 @@ Output: .. testcode:: ExGeneratePythonScriptFile + import os + #create a workspace and run some operations on it ws = CreateSampleWorkspace() ws = CropWorkspace(ws, XMin=7828.162291, XMax=11980.906921) ws = Power(ws, Exponent=1.5) ws = RenameWorkspace(ws, OutputWorkspace="MyTestWorkspace") - GeneratePythonScript(ws, Filename='myscript.py') + path = os.path.join(os.path.expanduser("~"), 'myscript.py') + GeneratePythonScript(ws, Filename=path) - with open ('myscript.py', 'r') as script: + with open (path, 'r') as script: print script.read().strip() Output: @@ -87,7 +90,7 @@ Output: def removeFiles(files): for ws in files: try: - path = os.path.join(config['defaultsave.directory'], ws) + path = os.path.join(os.path.expanduser("~"), ws) os.remove(path) except: pass diff --git a/Code/Mantid/docs/source/algorithms/OSIRISDiffractionReduction-v1.rst b/Code/Mantid/docs/source/algorithms/OSIRISDiffractionReduction-v1.rst index c049763d9ade..5108939a07ed 100644 --- a/Code/Mantid/docs/source/algorithms/OSIRISDiffractionReduction-v1.rst +++ b/Code/Mantid/docs/source/algorithms/OSIRISDiffractionReduction-v1.rst @@ -25,6 +25,8 @@ Usage .. testcode:: ExOSIRISDiffractionReductionSimple + import os + def createDummyOSIRISWorkspace(name, func, xmin, xmax, bin_width): """Creates a workspace that looks something like an OSIRIS diffraction run""" #create workspace according to function @@ -53,11 +55,12 @@ Usage #OSIRISDiffractionReduction currently only support loading from file. for ws in (samples + vanadium): - SaveNexus(ws, ws + ".nxs") + path = os.path.join(os.path.expanduser("~"), ws + ".nxs") + SaveNexus(ws, path) #run OSIRISDiffractionReduction - samples = [sample + ".nxs" for sample in samples] - vanadium = [van + ".nxs" for van in vanadium] + samples = [os.path.join(os.path.expanduser("~"), sample + ".nxs") for sample in samples] + vanadium = [os.path.join(os.path.expanduser("~"), van + ".nxs") for van in vanadium] ws = OSIRISDiffractionReduction(Sample=','.join(samples), Vanadium=','.join(vanadium), CalFile="osiris_041_RES10.cal") print "Number of Spectra: %d, Number of bins: %d" % (ws.getNumberHistograms(), ws.blocksize()) @@ -74,7 +77,6 @@ Output: def removeFiles(files): for ws in files: try: - path = os.path.join(config['defaultsave.directory'], ws) os.remove(path) except: pass diff --git a/Code/Mantid/docs/source/algorithms/SaveFocusedXYE-v1.rst b/Code/Mantid/docs/source/algorithms/SaveFocusedXYE-v1.rst index 298a31043379..f4b7a46d6405 100644 --- a/Code/Mantid/docs/source/algorithms/SaveFocusedXYE-v1.rst +++ b/Code/Mantid/docs/source/algorithms/SaveFocusedXYE-v1.rst @@ -40,9 +40,10 @@ Usage ws = ExtractSingleSpectrum(ws, 0) file_name = "myworkspace.ascii" - SaveFocusedXYE(ws, file_name) - - path = os.path.join(config['defaultsave.directory'], "myworkspace-0.ascii") + path = os.path.join(os.path.expanduser("~"), "myworkspace.ascii") + + SaveFocusedXYE(ws, path) + path = os.path.join(os.path.expanduser("~"), "myworkspace-0.ascii") print os.path.isfile(path) Output: @@ -57,7 +58,7 @@ Output: def removeFiles(files): for ws in files: try: - path = os.path.join(config['defaultsave.directory'], ws) + path = os.path.join(os.path.expanduser("~"), ws) os.remove(path) except: pass @@ -74,9 +75,9 @@ Output: ws = CropWorkspace(ws, StartWorkspaceIndex=0, EndWorkspaceIndex=4) file_name = "myworkspace.ascii" - SaveFocusedXYE(ws, file_name, SplitFiles=False, IncludeHeader=True, Format='MAUD') + path = os.path.join(os.path.expanduser("~"), file_name) - path = os.path.join(config['defaultsave.directory'], file_name) + SaveFocusedXYE(ws, path, SplitFiles=False, IncludeHeader=True, Format='MAUD') print os.path.isfile(path) @@ -92,7 +93,7 @@ Output: def removeFiles(files): for ws in files: try: - path = os.path.join(config['defaultsave.directory'], ws) + path = os.path.join(os.path.expanduser("~"), ws) os.remove(path) except: pass diff --git a/Code/Mantid/docs/source/algorithms/SaveGSS-v1.rst b/Code/Mantid/docs/source/algorithms/SaveGSS-v1.rst index b848263c4594..cc048c80acba 100644 --- a/Code/Mantid/docs/source/algorithms/SaveGSS-v1.rst +++ b/Code/Mantid/docs/source/algorithms/SaveGSS-v1.rst @@ -48,9 +48,11 @@ Usage ws = CreateSampleWorkspace() ws = ExtractSingleSpectrum(ws, WorkspaceIndex=0) file_name = "myworkspace.ascii" - SaveGSS(ws, file_name) + path = os.path.join(os.path.expanduser("~"), file_name) - path = os.path.join(config['defaultsave.directory'], "myworkspace-0.ascii") + SaveGSS(ws, path) + + path = os.path.join(os.path.expanduser("~"), "myworkspace-0.ascii") print os.path.isfile(path) @@ -66,7 +68,7 @@ Output: def removeFiles(files): for ws in files: try: - path = os.path.join(config['defaultsave.directory'], ws) + path = os.path.join(os.path.expanduser("~"), ws) os.remove(path) except: pass @@ -83,9 +85,9 @@ Output: #GSAS file cannot have more than 99 entries ws = CropWorkspace(ws, StartWorkspaceIndex=0, EndworkspaceIndex=98) file_name = "myworkspace.ascii" - SaveGSS(ws, file_name, SplitFiles=False, ExtendedHeader=True, UseSpectrumNumberAsBankID=True) + path = os.path.join(os.path.expanduser("~"), file_name) + SaveGSS(ws, path, SplitFiles=False, ExtendedHeader=True, UseSpectrumNumberAsBankID=True) - path = os.path.join(config['defaultsave.directory'], file_name) print os.path.isfile(path) Output: @@ -100,7 +102,7 @@ Output: def removeFiles(files): for ws in files: try: - path = os.path.join(config['defaultsave.directory'], ws) + path = os.path.join(os.path.expanduser("~"), ws) os.remove(path) except: pass diff --git a/Code/Mantid/docs/source/algorithms/SaveHKL-v1.rst b/Code/Mantid/docs/source/algorithms/SaveHKL-v1.rst index 4f107d395759..d876d7a31cb9 100644 --- a/Code/Mantid/docs/source/algorithms/SaveHKL-v1.rst +++ b/Code/Mantid/docs/source/algorithms/SaveHKL-v1.rst @@ -49,11 +49,12 @@ Usage import os + path = os.path.join(os.path.expanduser("~"), "MyPeaks.hkl") + #load a peaks workspace from file peaks = LoadIsawPeaks(Filename=r'Peaks5637.integrate') - SaveHKL(peaks, "MyPeaks.hkl") + SaveHKL(peaks, path) - path = os.path.join(config['defaultsave.directory'], "MyPeaks.hkl") print os.path.isfile(path) Output: @@ -68,7 +69,7 @@ Output: def removeFiles(files): for ws in files: try: - path = os.path.join(config['defaultsave.directory'], ws) + path = os.path.join(os.path.expanduser("~"), ws) os.remove(path) except: pass @@ -85,9 +86,9 @@ Output: peaks = LoadIsawPeaks(Filename=r'Peaks5637.integrate') print "Number of peaks in table %d" % peaks.rowCount() - SaveHKL(peaks, "MyPeaks.hkl", MinWavelength=0.5, MaxWavelength=2,MinDSpacing=0.2, SortBy='Bank') + path = os.path.join(os.path.expanduser("~"), "MyPeaks.hkl") + SaveHKL(peaks, path, MinWavelength=0.5, MaxWavelength=2,MinDSpacing=0.2, SortBy='Bank') - path = os.path.join(config['defaultsave.directory'], "MyPeaks.hkl") peaks = LoadHKL(path) print "Number of peaks in table %d" % peaks.rowCount() @@ -104,7 +105,7 @@ Output: def removeFiles(files): for ws in files: try: - path = os.path.join(config['defaultsave.directory'], ws) + path = os.path.join(os.path.expanduser("~"), ws) os.remove(path) except: pass diff --git a/Code/Mantid/docs/source/algorithms/SaveNexusProcessed-v1.rst b/Code/Mantid/docs/source/algorithms/SaveNexusProcessed-v1.rst index ed9026e18b4b..ed31f1c75987 100644 --- a/Code/Mantid/docs/source/algorithms/SaveNexusProcessed-v1.rst +++ b/Code/Mantid/docs/source/algorithms/SaveNexusProcessed-v1.rst @@ -55,9 +55,9 @@ Usage ws = CreateSampleWorkspace() file_name = "myworkspace.nxs" - SaveNexusProcessed(ws, file_name) + path = os.path.join(os.path.expanduser("~"), file_name) + SaveNexusProcessed(ws, path) - path = os.path.join(config['defaultsave.directory'], file_name) print os.path.isfile(path) Output: @@ -72,7 +72,7 @@ Output: def removeFiles(files): for ws in files: try: - path = os.path.join(config['defaultsave.directory'], ws) + path = os.path.join(os.path.expanduser("~"), ws) os.remove(path) except: pass @@ -88,12 +88,12 @@ Output: ws = CreateSampleWorkspace() file_name = "myworkspace.nxs" - SaveNexusProcessed(ws, file_name, Title="MyWorkspace", WorkspaceIndexMin=0, WorkspaceIndexMax=9) + path = os.path.join(os.path.expanduser("~"), file_name) + SaveNexusProcessed(ws, path, Title="MyWorkspace", WorkspaceIndexMin=0, WorkspaceIndexMax=9) - path = os.path.join(config['defaultsave.directory'], file_name) print os.path.isfile(path) - ws = Load(file_name) + ws = Load(path) print "Saved workspace has %d spectra" % ws.getNumberHistograms() Output: @@ -109,7 +109,7 @@ Output: def removeFiles(files): for ws in files: try: - path = os.path.join(config['defaultsave.directory'], ws) + path = os.path.join(os.path.expanduser("~"), ws) os.remove(path) except: pass @@ -124,12 +124,12 @@ Output: ws = CreateSampleWorkspace("Event") file_name = "myworkspace.nxs" - SaveNexusProcessed(ws, file_name, CompressNexus=True, PreserveEvents=True) + path = os.path.join(os.path.expanduser("~"), file_name) + SaveNexusProcessed(ws, path, CompressNexus=True, PreserveEvents=True) - path = os.path.join(config['defaultsave.directory'], file_name) print os.path.isfile(path) - ws = Load(file_name) + ws = Load(path) print "Saved workspace has %d spectra" % ws.getNumberHistograms() Output: @@ -145,7 +145,7 @@ Output: def removeFiles(files): for ws in files: try: - path = os.path.join(config['defaultsave.directory'], ws) + path = os.path.join(os.path.expanduser("~"), ws) os.remove(path) except: pass