Skip to content

Commit

Permalink
Workspace's setName method is made private. Tests are still failing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Jun 7, 2013
1 parent d746f85 commit 106e30d
Show file tree
Hide file tree
Showing 28 changed files with 58 additions and 55 deletions.
10 changes: 8 additions & 2 deletions Code/Mantid/Framework/API/inc/MantidAPI/Workspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ namespace Kernel

namespace API
{
//----------------------------------------------------------------------
// Forward Declaration
//----------------------------------------------------------------------
class AnalysisDataServiceImpl;

/** Base Workspace Abstract Class.
@author Laurent C Chapon, ISIS, RAL
Expand Down Expand Up @@ -67,8 +72,6 @@ class MANTID_API_DLL Workspace : public Kernel::DataItem

void virtual setTitle(const std::string&);
void setComment(const std::string&);
void setName(const std::string&);
//virtual const std::string& getTitle() const;
virtual const std::string getTitle() const;
const std::string& getComment() const;
const std::string& getName() const;
Expand All @@ -84,6 +87,7 @@ class MANTID_API_DLL Workspace : public Kernel::DataItem


private:
void setName(const std::string&);
/// The title of the workspace
std::string m_title;
/// A user-provided comment that is attached to the workspace
Expand All @@ -93,6 +97,8 @@ class MANTID_API_DLL Workspace : public Kernel::DataItem
/// The history of the workspace, algorithm and environment
WorkspaceHistory m_history;

friend class AnalysisDataServiceImpl;

};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ class MultiPeriodGroupAlgorithmTest : public CxxTest::TestSuite
{
MatrixWorkspace_sptr a = MatrixWorkspace_sptr(new WorkspaceTester);
MatrixWorkspace_sptr b = MatrixWorkspace_sptr(new WorkspaceTester);
a->setName(name + "_1");
b->setName(name + "_2");
//a->setName(name + "_1");
//b->setName(name + "_2");
WorkspaceGroup_sptr group = boost::make_shared<WorkspaceGroup>();
group->setName(name);
//group->setName(name);
group->addWorkspace(a);
group->addWorkspace(b);
add_periods_logs(group);
Expand Down Expand Up @@ -265,4 +265,4 @@ class MultiPeriodGroupAlgorithmTest : public CxxTest::TestSuite
};


#endif /* MANTID_API_MultiPeriodGroupAlgorithmTEST_H_ */
#endif /* MANTID_API_MultiPeriodGroupAlgorithmTEST_H_ */
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/test/WorkspaceGroupTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class WorkspaceGroupTest : public CxxTest::TestSuite
void test_areNamesSimilar()
{
WorkspaceGroup_sptr group(new WorkspaceGroup());
group->setName("name");
//group->setName("name");
TSM_ASSERT( "Empty group is not similar", !group->areNamesSimilar() );

boost::shared_ptr<WorkspaceTester> ws(new WorkspaceTester());
Expand Down
2 changes: 0 additions & 2 deletions Code/Mantid/Framework/Algorithms/src/DetectorDiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ namespace Mantid
// Perform FindDetectorsOutsideLimits and MedianDetectorTest on the
// detector vanadium
maskWS = this->doDetVanTest(inputWS, numFailed);
maskWS->setName(maskName);

// DetectorEfficiencyVariation (only if two workspaces are specified)
if (input2WS)
Expand Down Expand Up @@ -352,7 +351,6 @@ namespace Mantid
extract->setProperty("DetectorList", detList);
extract->executeAsChildAlg();
maskWS = extract->getProperty("OutputWorkspace");
maskWS->setName(maskName);

this->setProperty("OutputWorkspace", maskWS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ namespace Algorithms

// 1. Initialize:use dummy numbers for arguments, for event workspace it doesn't matter
outputWS = DataObjects::EventWorkspace_sptr(new DataObjects::EventWorkspace());
outputWS->setName("FilteredWorkspace");
//outputWS->setName("FilteredWorkspace");
outputWS->initialize(1,1,1);

// 2. Set the units
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class ExportTimeSeriesLogTest : public CxxTest::TestSuite
// 1. Empty workspace
DataObjects::EventWorkspace_sptr eventws =
WorkspaceCreationHelper::createEventWorkspaceWithFullInstrument(2, 2, true);
eventws->setName("TestWorkspace");
//eventws->setName("TestWorkspace");

// 2. Run star time
int64_t runstarttime_ns = 3000000000;
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Algorithms/test/FilterEventsTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class FilterEventsTest : public CxxTest::TestSuite
size_t numpulses = 5;

DataObjects::EventWorkspace_sptr eventws = createEventWorkspace(runstart_i64, pulsedt, tofdt, numpulses);
eventws->setName("Test01");
//eventws->setName("Test01");

TS_ASSERT_EQUALS(eventws->getNumberEvents(), 500);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class GenerateEventsFilterTest : public CxxTest::TestSuite
// 1. Empty workspace
DataObjects::EventWorkspace_sptr eventws =
WorkspaceCreationHelper::createEventWorkspaceWithFullInstrument(2, 2, true);
eventws->setName("TestWorkspace");
//eventws->setName("TestWorkspace");

// 2. Run star time
int64_t runstarttime_ns = 3000000000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class GetTimeSeriesLogInformationTest : public CxxTest::TestSuite
// 1. Empty workspace
DataObjects::EventWorkspace_sptr eventws =
WorkspaceCreationHelper::createEventWorkspaceWithFullInstrument(2, 2, true);
eventws->setName("TestWorkspace");
//eventws->setName("TestWorkspace");

// 2. Run star time
int64_t runstarttime_ns = 3000000000;
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Algorithms/test/InvertMaskTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class InvertMaskTest : public CxxTest::TestSuite
// 1. Create Mask Workspaces
Mantid::Geometry::Instrument_sptr inst1 = ComponentCreationHelper::createTestInstrumentCylindrical(5);
Mantid::DataObjects::MaskWorkspace_sptr ws1(new Mantid::DataObjects::MaskWorkspace(inst1));
ws1->setName("OriginalMask");
//ws1->setName("OriginalMask");
AnalysisDataService::Instance().addOrReplace("OriginalMask", ws1);

std::cout << "Input MaskWorkspace Size = " << ws1->getNumberHistograms() << std::endl;
Expand Down
26 changes: 13 additions & 13 deletions Code/Mantid/Framework/Algorithms/test/MergeRunsTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class MergeRunsTest : public CxxTest::TestSuite
{
MatrixWorkspace_sptr a = WorkspaceCreationHelper::Create2DWorkspace123(3,10,1);
MatrixWorkspace_sptr b = WorkspaceCreationHelper::Create2DWorkspace123(3,10,1);
a->setName("a1");
b->setName("b1");
//a->setName("a1");
//b->setName("b1");
WorkspaceGroup_sptr group = boost::make_shared<WorkspaceGroup>();
group->setName("group1");
//group->setName("group1");
group->addWorkspace(a);
group->addWorkspace(b); // No multiperiod logs added.
AnalysisDataService::Instance().addOrReplace(a->name(), a);
Expand All @@ -66,10 +66,10 @@ class MergeRunsTest : public CxxTest::TestSuite
{
MatrixWorkspace_sptr a = WorkspaceCreationHelper::Create2DWorkspace123(3,10,1);
MatrixWorkspace_sptr b = WorkspaceCreationHelper::Create2DWorkspace123(3,10,1);
a->setName("a2");
b->setName("b2");
//a->setName("a2");
//b->setName("b2");
WorkspaceGroup_sptr group = boost::make_shared<WorkspaceGroup>();
group->setName("group2");
//group->setName("group2");
group->addWorkspace(a);
group->addWorkspace(b); // No multiperiod logs added.
const bool calculateNPeriods = false;
Expand All @@ -86,10 +86,10 @@ class MergeRunsTest : public CxxTest::TestSuite
{
MatrixWorkspace_sptr a = WorkspaceCreationHelper::Create2DWorkspace123(3,10,1);
MatrixWorkspace_sptr b = WorkspaceCreationHelper::Create2DWorkspace123(3,10,1);
a->setName("a4");
b->setName("b4");
//a->setName("a4");
//b->setName("b4");
WorkspaceGroup_sptr group = boost::make_shared<WorkspaceGroup>();
group->setName("group4");
//group->setName("group4");
group->addWorkspace(a);
group->addWorkspace(b); // No multiperiod logs added.
const bool calculateNPeriods = false;
Expand All @@ -106,10 +106,10 @@ class MergeRunsTest : public CxxTest::TestSuite
{
MatrixWorkspace_sptr a = WorkspaceCreationHelper::Create2DWorkspace123(3,10,1);
MatrixWorkspace_sptr b = WorkspaceCreationHelper::Create2DWorkspace123(3,10,1);
a->setName("a3");
b->setName("b3");
//a->setName("a3");
//b->setName("b3");
WorkspaceGroup_sptr group = boost::make_shared<WorkspaceGroup>();
group->setName("group3");
//group->setName("group3");
group->addWorkspace(a);
group->addWorkspace(b);
add_periods_logs(group);
Expand Down Expand Up @@ -710,7 +710,7 @@ class MergeRunsTest : public CxxTest::TestSuite
WorkspaceGroup_sptr aCorrupted = boost::make_shared<WorkspaceGroup>();
aCorrupted->addWorkspace(second);
aCorrupted->addWorkspace(first);
aCorrupted->setName("aCorrupted");
//aCorrupted->setName("aCorrupted");
Mantid::API::AnalysisDataService::Instance().addOrReplace(aCorrupted->getName(), aCorrupted);

do_test_validation_throws(aCorrupted, a);
Expand Down
2 changes: 0 additions & 2 deletions Code/Mantid/Framework/Crystal/src/IntegratePeakTimeSlices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,6 @@ namespace Mantid
void IntegratePeakTimeSlices::InitializeColumnNamesInTableWorkspace(
TableWorkspace_sptr &TabWS)
{
TabWS->setName("Log Table");
TabWS->addColumn("double", "Time");
TabWS->addColumn("double", "Channel");
TabWS->addColumn("double", "Background");
Expand Down Expand Up @@ -2083,7 +2082,6 @@ namespace Mantid
ws->setData(2, Yvals);
AttributeValues->setHeightHalfWidthInfo(xvals,Yvals,yvals);

ws->setName("index0");
StatBase[IStartRow] = minRow;
StatBase[IStartCol] =minCol;
StatBase[INRows] = maxRow-minRow+1;
Expand Down
1 change: 0 additions & 1 deletion Code/Mantid/Framework/Crystal/src/LoadHKL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ namespace Crystal

std::string filename = getPropertyValue("Filename");
PeaksWorkspace_sptr ws(new PeaksWorkspace());
ws->setName(getProperty("OutputWorkspace"));

std::fstream in;
in.open( filename.c_str(), std::ios::in);
Expand Down
1 change: 0 additions & 1 deletion Code/Mantid/Framework/Crystal/src/LoadIsawPeaks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ namespace Crystal
{
// Create the workspace
PeaksWorkspace_sptr ws(new PeaksWorkspace());
ws->setName(getPropertyValue("OutputWorkspace"));

// This loads (appends) the peaks
this->appendFile( ws, getPropertyValue("Filename") );
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Crystal/src/SCDCalibratePanels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ namespace Mantid
Workspace2D_sptr ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>(wsM);
ws->setInstrument(newInstr);
ws->populateInstrumentParameters();
ws->setName("rrrr");
//ws->setName("rrrr");

boost::shared_ptr<Algorithm> loadParFile = createChildAlgorithm("LoadParameterFile");
loadParFile->initialize();
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Crystal/test/CentroidPeaksTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class CentroidPeaksTest : public CxxTest::TestSuite

// Create the peaks workspace
PeaksWorkspace_sptr pkws(new PeaksWorkspace());
pkws->setName("TOPAZ");
//pkws->setName("TOPAZ");

// Create a single peak on that particular detector
Peak PeakObj(in_ws->getInstrument(),5050,2.,V3D(1,1,1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ class IntegratePeakTimeSlicesTest: public CxxTest::TestSuite
pks->addPeak(peak);

IntegratePeakTimeSlices algP;
wsPtr->setName("InputWorkspace");
pks->setName("PeaksWorkspace");
//wsPtr->setName("InputWorkspace");
//pks->setName("PeaksWorkspace");
try
{
algP.initialize();
Expand Down Expand Up @@ -358,7 +358,7 @@ TotIntensityError 72.7901 90.9626 109.655 125.595 109.655
Peak peak(instP, pixelp->getID(), 6.955836);

PeaksWorkspace_sptr pks(new PeaksWorkspace());
pks->setName("Peaks3");
//pks->setName("Peaks3");
pks->addPeak(peak);

IntegratePeakTimeSlices algP;
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/Crystal/test/MaskPeaksWorkspaceTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MaskPeaksWorkspaceTest : public CxxTest::TestSuite

// Create the peaks workspace
PeaksWorkspace_sptr pkws(new PeaksWorkspace());
pkws->setName("TOPAZ");
//pkws->setName("TOPAZ");

// This loads (appends) the peaks
Mantid::DataObjects::Peak PeakObj(inputW->getInstrument(),1000,100.);
Expand Down Expand Up @@ -118,7 +118,7 @@ class MaskPeaksWorkspaceTest : public CxxTest::TestSuite

// Create the peaks workspace
PeaksWorkspace_sptr pkws(new PeaksWorkspace());
pkws->setName("TOPAZ");
//pkws->setName("TOPAZ");

// This loads (appends) the peaks
Mantid::DataObjects::Peak PeakObj(inputW->getInstrument(),1000, 1.);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class OptimizeCrystalPlacementTest: public CxxTest::TestSuite
loadUB.setProperty("Filename", "ls5637.mat");
loadUB.execute();

peaks->setName("abcd");
//peaks->setName("abcd");

}
void test_basic()
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Crystal/test/PeakIntegrationTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class PeakIntegrationTest : public CxxTest::TestSuite

// Create the peaks workspace
PeaksWorkspace_sptr pkws(new PeaksWorkspace());
pkws->setName("TOPAZ");
//pkws->setName("TOPAZ");

// Create a single peak on that particular detector
Peak PeakObj(in_ws->getInstrument(),5050,2.,V3D(1,1,1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SCDCalibratePanelsTest : public CxxTest::TestSuite
alg= AlgorithmFactory::Instance().create("SCDCalibratePanels", 1);

alg->initialize();
Peakws->setName("PeaksWsp");
//Peakws->setName("PeaksWsp");
alg->setProperty("PeakWorkspace", Peakws );

alg->setProperty("a",14.0);
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Crystal/test/SortHKLTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SortHKLTest : public CxxTest::TestSuite
Instrument_sptr inst = ComponentCreationHelper::createTestInstrumentRectangular(4, 10, 1.0);
PeaksWorkspace_sptr ws(new PeaksWorkspace());
ws->setInstrument(inst);
ws->setName("TOPAZ_peaks");
//ws->setName("TOPAZ_peaks");
double smu = 0.357;
double amu = 0.011;
NeutronAtom *neutron = new NeutronAtom(static_cast<uint16_t>(EMPTY_DBL()), static_cast<uint16_t>(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ namespace DataHandling
// LoadInstrument adds the workspace to ADS as Anonymous
// we don't want it there
API::AnalysisDataService::Instance().remove("Anonymous");
localWorkspace->setName("");
}
}

Expand Down
14 changes: 9 additions & 5 deletions Code/Mantid/Framework/DataHandling/src/Load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ namespace Mantid
Workspace_sptr secondWS = loadFileToWs(*filename, "__@loadsum_temp@");
sumWS = plusWs(sumWS, secondWS);
}
sumWS->setName(*wsName);

API::WorkspaceGroup_sptr group = boost::dynamic_pointer_cast<WorkspaceGroup>(sumWS);
if(group)
Expand All @@ -502,7 +501,9 @@ namespace Mantid
for( ; childWsName != childWsNames.end(); ++childWsName, ++count )
{
Workspace_sptr childWs = group->getItem(*childWsName);
childWs->setName(group->getName() + "_" + boost::lexical_cast<std::string>(count));
const std::string childName = group->getName() + "_" + boost::lexical_cast<std::string>(count);
API::AnalysisDataService::Instance().addOrReplace(childName, childWs);
//childWs->setName(group->getName() + "_" + boost::lexical_cast<std::string>(count));
}
}
// Add the sum to the list of loaded workspace names.
Expand All @@ -527,7 +528,9 @@ namespace Mantid
if( *childWsName == outputWsName )
{
Mantid::API::Workspace_sptr child = group->getItem(*childWsName);
child->setName(child->getName() + "_" + boost::lexical_cast<std::string>(count));
//child->setName(child->getName() + "_" + boost::lexical_cast<std::string>(count));
const std::string childName = child->getName() + "_" + boost::lexical_cast<std::string>(count);
API::AnalysisDataService::Instance().addOrReplace(childName, child);
count++;
}
}
Expand Down Expand Up @@ -745,7 +748,8 @@ namespace Mantid
loadAlg->executeAsChildAlg();

Workspace_sptr ws = loadAlg->getProperty("OutputWorkspace");
ws->setName(wsName);
//ws->setName(wsName);
AnalysisDataService::Instance().addOrReplace(wsName, ws);
return ws;
}

Expand Down Expand Up @@ -828,7 +832,7 @@ namespace Mantid
{
Workspace_sptr childWs = isGroup->getItem(*childName);
isGroup->remove(*childName);
childWs->setName(isGroup->getName() + "_" + boost::lexical_cast<std::string>(count));
//childWs->setName(isGroup->getName() + "_" + boost::lexical_cast<std::string>(count));
group->addWorkspace(childWs);
}
}
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/DataHandling/test/LoadTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ class LoadTest : public CxxTest::TestSuite

void testList()
{
AnalysisDataService::Instance().clear();
Load loader;
loader.initialize();
loader.setPropertyValue("Filename", "MUSR15189,15190,15191.nxs");
Expand Down

0 comments on commit 106e30d

Please sign in to comment.