Skip to content

Commit

Permalink
refs #4895. HistoWs masking methods
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Feb 28, 2012
1 parent 575c3f2 commit fa59b63
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,13 @@ namespace MDEvents
return std::sqrt(m_errorsSquared[index1 + indexMultiplier[0]*index2 + indexMultiplier[1]*index3 + indexMultiplier[2]*index4]);
}


/**
Getter for the masking at a specified linear index.
*/
bool getIsMaskedAt(size_t index) const
{
return m_masks[index];
}

/// Get the signal at the specified index.
signal_t getSignalAt(size_t index) const
Expand Down Expand Up @@ -384,6 +390,9 @@ namespace MDEvents
/// Max index into each dimension
size_t * m_indexMax;

/// Linear array of masks for each bin
bool * m_masks;

};

/// A shared pointer to a MDHistoWorkspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace MDEvents

virtual signal_t getInnerError(size_t index) const;

virtual bool getIsMasked() const{ throw std::runtime_error("MDHistoWorkspaceIterator::getIsMasked no implemented yet.");}
virtual bool getIsMasked() const;

protected:
/// The MDHistoWorkspace being iterated.
Expand Down
5 changes: 5 additions & 0 deletions Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ namespace MDEvents
// Allocate the linear arrays
m_signals = new signal_t[m_length];
m_errorsSquared = new signal_t[m_length];
m_masks = new bool[m_length];
// Now copy all the data
for (size_t i=0; i<m_length; ++i)
{
m_signals[i] = other.m_signals[i];
m_errorsSquared[i] = other.m_errorsSquared[i];
m_masks[i] = other.m_masks[i];
}
}

Expand All @@ -85,6 +87,7 @@ namespace MDEvents
delete [] m_indexMaker;
delete [] m_indexMax;
delete [] m_origin;
delete [] m_masks;
}

//----------------------------------------------------------------------------------------------
Expand All @@ -101,6 +104,7 @@ namespace MDEvents
// Allocate the linear arrays
m_signals = new signal_t[m_length];
m_errorsSquared = new signal_t[m_length];
m_masks = new bool[m_length];

// Initialize them to NAN (quickly)
signal_t nan = std::numeric_limits<signal_t>::quiet_NaN();
Expand Down Expand Up @@ -157,6 +161,7 @@ namespace MDEvents
{
m_signals[i] = signal;
m_errorsSquared[i] = errorSquared;
m_masks[i] = false; //Not masked by default;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ namespace MDEvents
return m_ws->getErrorAt(m_pos);
}

bool MDHistoWorkspaceIterator::getIsMasked() const
{
return m_ws->getIsMaskedAt(m_pos);
}

} // namespace Mantid
} // namespace MDEvents

Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,13 @@ class MDHistoWorkspaceIteratorTestPerformance : public CxxTest::TestSuite
{
//Characterisation test
MDHistoWorkspaceIterator iterator(ws);
TSM_ASSERT_THROWS("Not implemented yet, should throw.", iterator.getIsMasked(), std::runtime_error);
for(size_t i =0; i < ws->getNPoints(); ++i)
{
std::stringstream stream;
stream << "Masking is different from the workspace at index: " << i;
TSM_ASSERT_EQUALS(stream.str(), ws->getIsMaskedAt(i), iterator.getIsMasked());
iterator.next();
}
}

};
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class MDHistoWorkspaceTest : public CxxTest::TestSuite
TS_ASSERT( boost::math::isnan( ws.getErrorAt(i) ));
TS_ASSERT( boost::math::isnan( ws.getSignalNormalizedAt(i) ));
TS_ASSERT( boost::math::isnan( ws.getErrorNormalizedAt(i) ));
TS_ASSERT( !ws.getIsMaskedAt(i));
}

// Setting and getting
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Vates/VatesAPI/src/vtkSplatterPlotFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ namespace Mantid
*/
vtkDataSet* vtkSplatterPlotFactory::create(ProgressAction& progressUpdating) const
{
UNUSED_ARG(progressUpdating);
validate();

size_t nd = m_workspace->getNumDims();
Expand Down

0 comments on commit fa59b63

Please sign in to comment.