Skip to content

Commit

Permalink
refs #11056. No default OL in test creation.
Browse files Browse the repository at this point in the history
Also fix segfault on PeaksViewer menu option, when no peaks are present, requesting size of the peak information.
  • Loading branch information
OwenArnold committed Feb 16, 2015
1 parent 4812d3a commit 2dbf18d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
Expand Up @@ -54,15 +54,15 @@ def test_interface(self):
self.assertTrue(not pws.hasIntegratedPeaks())

def test_createPeakHKL(self):
pws = WorkspaceCreationHelper.createPeaksWorkspace(0)
pws = WorkspaceCreationHelper.createPeaksWorkspace(0, True)
lattice = pws.mutableSample().getOrientedLattice()

# Simple test that the creational method is exposed
p = pws.createPeakHKL([1,1,1])
self.assertTrue(IPeak != None)

def test_peak_setQLabFrame(self):
pws = WorkspaceCreationHelper.createPeaksWorkspace(1)
pws = WorkspaceCreationHelper.createPeaksWorkspace(1, True)
p = pws.getPeak(0)
try:
p.setQLabFrame(V3D(1,1,1))
Expand All @@ -75,7 +75,7 @@ def test_peak_setQLabFrame(self):
self.fail("Tried setQLabFrame with one V3D argument and a double distance")

def test_peak_setQSampleFrame(self):
pws = WorkspaceCreationHelper.createPeaksWorkspace(1)
pws = WorkspaceCreationHelper.createPeaksWorkspace(1, True)
p = pws.getPeak(0)
try:
p.setQSampleFrame(V3D(1,1,1))
Expand Down
Expand Up @@ -69,10 +69,12 @@ BOOST_PYTHON_MODULE(WorkspaceCreationHelper)

//=================================== Peak Workspaces ===================================

// Forces the returns the be IEventWorkspace_sptr
// Forces the returns the be IPeaks_sptr
typedef IPeaksWorkspace_sptr (*Signature1_Peaks)(const int);
typedef IPeaksWorkspace_sptr (*Signature2_Peaks)(const int, const bool);

def("createPeaksWorkspace", (Signature1_Peaks)&createPeaksWorkspace);
def("createPeaksWorkspace", (Signature2_Peaks)&createPeaksWorkspace);

//=================================== MD Workspaces ===================================

Expand Down
Expand Up @@ -294,7 +294,7 @@ Mantid::DataObjects::RebinnedOutput_sptr CreateRebinnedOutputWorkspace();

/// Create a simple peaks workspace containing the given number of peaks
boost::shared_ptr<Mantid::DataObjects::PeaksWorkspace>
createPeaksWorkspace(const int numPeaks = 2);
createPeaksWorkspace(const int numPeaks = 2, const bool createOrientedLattice=false);
/**Build table workspace with preprocessed detectors for existign worksapce with
* instrument */
boost::shared_ptr<Mantid::DataObjects::TableWorkspace>
Expand Down
Expand Up @@ -1182,7 +1182,7 @@ RebinnedOutput_sptr CreateRebinnedOutputWorkspace() {
}

Mantid::DataObjects::PeaksWorkspace_sptr
createPeaksWorkspace(const int numPeaks) {
createPeaksWorkspace(const int numPeaks, const bool createOrientedLattice) {
PeaksWorkspace_sptr peaksWS(new PeaksWorkspace());
Instrument_sptr inst =
ComponentCreationHelper::createTestInstrumentRectangular2(1, 10);
Expand All @@ -1193,8 +1193,10 @@ createPeaksWorkspace(const int numPeaks) {
peaksWS->addPeak(peak);
}

Mantid::Geometry::OrientedLattice lattice;
peaksWS->mutableSample().setOrientedLattice(&lattice);
if(createOrientedLattice) {
Mantid::Geometry::OrientedLattice lattice;
peaksWS->mutableSample().setOrientedLattice(&lattice);
}
return peaksWS;
}

Expand Down
Expand Up @@ -451,15 +451,15 @@ void ConcretePeaksPresenter::setPeakSizeIntoProjection(const double fraction) {

double ConcretePeaksPresenter::getPeakSizeOnProjection() const {
double result = 0;
if (m_viewPeaks != NULL && m_viewPeaks->positionOnly()) {
if (m_viewPeaks != NULL && (m_peaksWS->getNumberPeaks() > 0) && m_viewPeaks->positionOnly()) {
result = m_viewPeaks->getOccupancyInView();
}
return result;
}

double ConcretePeaksPresenter::getPeakSizeIntoProjection() const {
double result = 0;
if (m_viewPeaks != NULL && m_viewPeaks->positionOnly()) {
if (m_viewPeaks != NULL && (m_peaksWS->getNumberPeaks() > 0) && m_viewPeaks->positionOnly()) {
result = m_viewPeaks->getOccupancyIntoView();
}
return result;
Expand Down

0 comments on commit 2dbf18d

Please sign in to comment.