Skip to content

Commit

Permalink
Merge release-next into ornl-next
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-builder committed May 10, 2024
2 parents e34140c + b837b6b commit 149d5f8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Framework/Algorithms/src/FindPeaks.cpp
Expand Up @@ -403,6 +403,12 @@ void FindPeaks::findPeaksUsingMariscotti() {
if (!(w % 2))
++w;

if (!m_dataWS->isRaggedWorkspace() && (m_dataWS->blocksize() <= static_cast<size_t>(w))) {
std::stringstream errss;
errss << "Block size of the workspace should be greater than:" << w;
throw std::runtime_error(errss.str());
}

smoothData(smoothedData, w, g_z);

// Now calculate the errors on the smoothed data
Expand Down
14 changes: 14 additions & 0 deletions Framework/Algorithms/test/FindPeaksTest.h
Expand Up @@ -302,6 +302,20 @@ class FindPeaksTest : public CxxTest::TestSuite {
AnalysisDataService::Instance().remove(WKSP_NAME_OUTPUT);
}

void testWhenSingleBinWs() {
MatrixWorkspace_sptr dataws = WorkspaceCreationHelper::create2DWorkspace(10, 1);
std::string wsName("SingleBinTestData");
AnalysisDataService::Instance().addOrReplace(wsName, dataws);
FindPeaks finder;
finder.setRethrows(true);

if (!finder.isInitialized())
finder.initialize();
TS_ASSERT_THROWS_NOTHING(finder.setPropertyValue("InputWorkspace", wsName));
TS_ASSERT_THROWS_NOTHING(finder.setPropertyValue("PeaksList", "peakslist"));
TSM_ASSERT_THROWS("Block size is not sufficient to run FindSXPeaks", finder.execute(), std::runtime_error &);
}

//----------------------------------------------------------------------------------------------
/** Parse a row in output parameter tableworkspace to a string/double
* parameter name/value map
Expand Down
4 changes: 2 additions & 2 deletions buildconfig/CMake/CppCheck_Suppressions.txt.in
Expand Up @@ -208,8 +208,8 @@ constParameterReference:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/GetEiMonDet
knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/FilterEvents.cpp:620
constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/FilterEvents.cpp:304
shadowVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/GetDetectorOffsets.cpp:148
knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/FindPeaks.cpp:886
knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/FindPeaks.cpp:993
knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/FindPeaks.cpp:892
knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/FindPeaks.cpp:999
constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/GetEi2.cpp:213
knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/MaskBinsIf.cpp:107
passedByValue:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/GeneratePeaks.cpp:662
Expand Down
@@ -0,0 +1 @@
- Fixed a crash in :ref:`FindPeaks <algm-FindPeaks>` when the number of bins in the workspace are not sufficient to run SmoothData:ref:`algm-SmoothData` algorithm and raise the error instead.

0 comments on commit 149d5f8

Please sign in to comment.