Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bugfix/8266_savegss_boolean'
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Oct 31, 2013
2 parents 0310fa2 + aa589d7 commit 01d0f4a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
16 changes: 6 additions & 10 deletions Code/Mantid/Framework/DataHandling/src/SaveFocusedXYE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ void SaveFocusedXYE::init()
"The name of the workspace containing the data you wish to save");
declareProperty(new API::FileProperty("Filename", "", API::FileProperty::Save),
"The filename to use when saving data");
std::vector<std::string> Split(2);
Split[0] = "True";
Split[1] = "False";
declareProperty("SplitFiles", "True", boost::make_shared<Kernel::StringListValidator>(Split),
declareProperty("SplitFiles", true,
"Save each spectrum in a different file (default true)");
declareProperty("StartAtBankNumber", 0, "Start bank (spectrum) numbers at this number in the file. "
"The bank number in the file will be the workspace index + StartAtBankNumber.");
Expand Down Expand Up @@ -95,8 +92,7 @@ void SaveFocusedXYE::exec()
g_log.error() << "Starting bank number cannot be less than 0. " << std::endl;
throw std::invalid_argument("Incorrect starting bank number");
}

std::string split = getProperty("SplitFiles");
bool split = getProperty("SplitFiles");
std::ostringstream number;
std::fstream out;
using std::ios_base;
Expand Down Expand Up @@ -137,7 +133,7 @@ void SaveFocusedXYE::exec()
}
}

if (split == "False" && out) // Assign only one file
if ((!split) && out) // Assign only one file
{
const std::string file(filename + '.' + ext);
Poco::File fileObj(file);
Expand All @@ -146,7 +142,7 @@ void SaveFocusedXYE::exec()
if (headers && (!exists || !append))
writeHeaders(out, inputWS);
}
else if (split == "True")//Several files will be created with names: filename-i.ext
else if (split)//Several files will be created with names: filename-i.ext
{
number << "-" << i + startingbank;
const std::string file(filename + number.str() + "." + ext);
Expand Down Expand Up @@ -193,14 +189,14 @@ void SaveFocusedXYE::exec()
<< std::setw(18) << E[j] << "\n";
}
//Close at each iteration
if (split == "True")
if (split)
{
out.close();
}
progress.report();
}
// Close if single file
if (split == "False")
if (!split)
{
out.close();
}
Expand Down
8 changes: 2 additions & 6 deletions Code/Mantid/Framework/DataHandling/src/SaveGSS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ namespace Mantid
"The input workspace, which must be in time-of-flight");
declareProperty(new API::FileProperty("Filename", "", API::FileProperty::Save),
"The filename to use for the saved data");
std::vector<std::string> Split(2);
Split[0] = "True";
Split[1] = "False";
declareProperty("SplitFiles", "True", boost::make_shared<Kernel::StringListValidator>(Split),
declareProperty("SplitFiles", true,
"Whether to save each spectrum into a separate file ('true') or not ('false'). Note that this is a string, not a boolean property.");
declareProperty("Append", true, "If true and Filename already exists, append, else overwrite ");
declareProperty(
Expand Down Expand Up @@ -132,8 +129,7 @@ namespace Mantid

const int bank = getProperty("Bank");
const bool MultiplyByBinWidth = getProperty("MultiplyByBinWidth");
std::string split_string = getProperty("SplitFiles");
bool split = (split_string == "True");
const bool split = getProperty("SplitFiles");
std::string outputFormat = getProperty("Format");

m_useSpecAsBank = getProperty("UseSpectrumNumberAsBankID");
Expand Down
12 changes: 6 additions & 6 deletions Code/Mantid/Framework/DataHandling/test/SaveFocussedXYETest.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SaveFocussedXYETest : public CxxTest::TestSuite
std::string filename("focussed.test");
saveXYE.setPropertyValue("Filename", filename);
filename = saveXYE.getPropertyValue("Filename"); //absolute path
saveXYE.setPropertyValue("SplitFiles", "False");
saveXYE.setProperty("SplitFiles", false);

TS_ASSERT_THROWS_NOTHING(saveXYE.execute());

Expand Down Expand Up @@ -130,7 +130,7 @@ class SaveFocussedXYETest : public CxxTest::TestSuite
std::string filename("focussed.txt");
saveXYE.setPropertyValue("Filename", filename);
filename = saveXYE.getPropertyValue("Filename"); //get the absolute path
saveXYE.setPropertyValue("SplitFiles", "False");
saveXYE.setProperty("SplitFiles", false);
saveXYE.setPropertyValue("Append", "0");

TS_ASSERT_THROWS_NOTHING(saveXYE.execute());
Expand Down Expand Up @@ -219,7 +219,7 @@ class SaveFocussedXYETest : public CxxTest::TestSuite
std::string filename("SaveGSS.txt");
saveGSS.setPropertyValue("Filename", filename);
filename = saveGSS.getPropertyValue("Filename"); //absolute path
saveGSS.setPropertyValue("SplitFiles", "False");
saveGSS.setProperty("SplitFiles", false);
saveGSS.setPropertyValue("Append", "0");
saveGSS.setPropertyValue("MultiplyByBinWidth", "1");

Expand Down Expand Up @@ -299,7 +299,7 @@ class SaveFocussedXYETest : public CxxTest::TestSuite
std::string filename("SaveGSS.txt");
saveGSS.setPropertyValue("Filename", filename);
filename = saveGSS.getPropertyValue("Filename"); //absolute path
saveGSS.setPropertyValue("SplitFiles", "False");
saveGSS.setProperty("SplitFiles", false);
saveGSS.setPropertyValue("Append", "0");
saveGSS.setPropertyValue("MultiplyByBinWidth", "0");

Expand Down Expand Up @@ -369,7 +369,7 @@ class SaveFocussedXYETest : public CxxTest::TestSuite
std::string filename("focussed.test");
saveXYE.setPropertyValue("Filename", filename);
filename = saveXYE.getPropertyValue("Filename"); //absolute path
saveXYE.setPropertyValue("SplitFiles", "False");
saveXYE.setProperty("SplitFiles", false);

TS_ASSERT_THROWS_NOTHING(saveXYE.execute());

Expand Down Expand Up @@ -417,7 +417,7 @@ class SaveFocussedXYETest : public CxxTest::TestSuite
saveXYE.setPropertyValue("InputWorkspace","ws");
saveXYE.setPropertyValue("Filename",filename);
filename = saveXYE.getPropertyValue("Filename"); //absolute path
saveXYE.setPropertyValue("SplitFiles", "False");
saveXYE.setProperty("SplitFiles", false);
saveXYE.execute();
TS_ASSERT( saveXYE.isExecuted() );
Poco::File focusfile(filename);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -939,12 +939,12 @@ def _save(self, wksp, info, normalized, pdfgetn):
if "pdfgetn" in self._outTypes:
pdfwksp = str(wksp)+"_norm"
pdfwksp = api.SetUncertainties(InputWorkspace=wksp, OutputWorkspace=pdfwksp, SetError="sqrt")
api.SaveGSS(InputWorkspace=pdfwksp, Filename=filename+".getn", SplitFiles="False", Append=False,
api.SaveGSS(InputWorkspace=pdfwksp, Filename=filename+".getn", SplitFiles=False, Append=False,
MultiplyByBinWidth=False, Bank=info.bank, Format="SLOG", ExtendedHeader=True)
api.DeleteWorkspace(pdfwksp)
return # don't do the other bits of saving
if "gsas" in self._outTypes:
api.SaveGSS(InputWorkspace=wksp, Filename=filename+".gsa", SplitFiles="False", Append=False,
api.SaveGSS(InputWorkspace=wksp, Filename=filename+".gsa", SplitFiles=False, Append=False,
MultiplyByBinWidth=normalized, Bank=info.bank, Format="SLOG", ExtendedHeader=True)
if "fullprof" in self._outTypes:
api.SaveFocusedXYE(InputWorkspace=wksp, StartAtBankNumber=info.bank, Filename=filename+".dat")
Expand Down

0 comments on commit 01d0f4a

Please sign in to comment.