Skip to content

Commit

Permalink
Merge pull request #38469 from mantidproject/ornl-next
Browse files Browse the repository at this point in the history
Ready release candidate v6.11.0.2rc2
  • Loading branch information
KedoKudo authored Dec 4, 2024
2 parents 4d4f513 + 99b83a2 commit a54c844
Show file tree
Hide file tree
Showing 117 changed files with 456 additions and 361 deletions.
2 changes: 1 addition & 1 deletion Framework/API/src/NumericAxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ std::string NumericAxis::formatLabel(const double value) const {
if (*it == '0') {
it = numberLabel.erase(it);
} else if (*it == '.') {
it = numberLabel.erase(it);
numberLabel.erase(it);
break;
} else {
break;
Expand Down
2 changes: 1 addition & 1 deletion Framework/API/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-maybe-uninitialized)
add_compile_options(-Wno-uninitialized)
endif()

if(CXXTEST_FOUND)
Expand Down
6 changes: 3 additions & 3 deletions Framework/API/test/FileFinderTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,9 @@ class FileFinderTest : public CxxTest::TestSuite {
TS_ASSERT(fileOn3.exists());
TS_ASSERT(fileOn4.exists());
#else
TS_ASSERT_THROWS_ANYTHING(fileOn2.exists());
TS_ASSERT_THROWS_ANYTHING(fileOn3.exists());
TS_ASSERT_THROWS_ANYTHING(fileOn4.exists());
TS_ASSERT(!fileOn2.exists());
TS_ASSERT(!fileOn3.exists());
TS_ASSERT(!fileOn4.exists());
#endif

fileFinder.setCaseSensitive(startingCaseOption);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MANTID_ALGORITHMS_DLL FindPeaksConvolve : public API::Algorithm {
bool m_centreBins;
Eigen::VectorXd m_pdf;
std::vector<std::string> m_intermediateWsNames;
std::mutex mtx;
std::mutex m_mtx;

void init() override;
void exec() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ void CalculateCarpenterSampleCorrection::exec() {
// Initialize progress reporting.
Progress prog(this, 0.0, 1.0, NUM_HIST);

EventWorkspace_sptr inputWkspEvent = std::dynamic_pointer_cast<EventWorkspace>(inputWksp);

// Create the new correction workspaces
MatrixWorkspace_sptr absWksp = createOutputWorkspace(inputWksp, "Attenuation factor");
MatrixWorkspace_sptr msWksp = createOutputWorkspace(inputWksp, "Multiple scattering factor");
Expand Down
24 changes: 14 additions & 10 deletions Framework/Algorithms/src/FindPeaksConvolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ void FindPeaksConvolve::exec() {
}
PARALLEL_FOR_IF(Kernel::threadSafe(*m_inputDataWS))
for (int i = 0; i < static_cast<int>(m_specCount); i++) {
PARALLEL_START_INTERRUPT_REGION
performConvolution(i);
PARALLEL_END_INTERRUPT_REGION
}
PARALLEL_CHECK_INTERRUPT_REGION

outputResults();
}

Expand Down Expand Up @@ -186,7 +190,6 @@ void FindPeaksConvolve::performConvolution(const size_t dataIndex) {
" exceeds the range of the x axis. Please reduce the peak extent.");
} else {
const Tensor1D kernel{createKernel(static_cast<int>(kernelBinCount.first))};

const auto binCount{m_inputDataWS->getNumberBins(specNum)};
// Edge handling is performed by padding the input data with 0 values. Each convolution requires a padding of kernel
// size + 1. The 1st conv is performed with a kernel of size n, the second size n/2. The resultant pad is split
Expand All @@ -198,20 +201,16 @@ void FindPeaksConvolve::performConvolution(const size_t dataIndex) {
const auto yData_padded{yData.pad(paddings)};
const Eigen::array<ptrdiff_t, 1> dims({0});
const Tensor1D yConvOutput{yData_padded.convolve(kernel, dims)};

const auto eData{TensorMap_const{&m_inputDataWS->e(specNum).front(), binCount}.pad(paddings)};
const Tensor1D eConvOutput{eData.square().convolve(kernel.square(), dims).sqrt()};

const Tensor1D smoothKernel{
createSmoothKernel(static_cast<size_t>(std::ceil(static_cast<double>(kernelBinCount.first) / 2.0)))};
Tensor1D iOverSig{(yConvOutput / eConvOutput).unaryExpr([](double val) { return std::isfinite(val) ? val : 0.0; })};
const Tensor1D iOverSigConvOutput{iOverSig.convolve(smoothKernel, dims)};

extractPeaks(dataIndex, iOverSigConvOutput, xData, yData, kernelBinCount.first / 2);

if (m_createIntermediateWorkspaces) {
auto wsNames = createIntermediateWorkspaces(dataIndex, kernel, iOverSigConvOutput, xData);
std::lock_guard<std::mutex> lock(mtx);
std::lock_guard<std::mutex> lock(m_mtx);
m_intermediateWsNames.insert(m_intermediateWsNames.end(), wsNames.cbegin(), wsNames.cend());
}
}
Expand Down Expand Up @@ -310,6 +309,7 @@ void FindPeaksConvolve::storePeakResults(const size_t dataIndex,
if (peakCount > m_maxPeakCount) {
m_maxPeakCount = peakCount;
}
std::lock_guard<std::mutex> lock(m_mtx);
m_peakResults[dataIndex] = std::move(peakCentres);
}
}
Expand All @@ -336,14 +336,18 @@ size_t FindPeaksConvolve::findPeakInRawData(const int xIndex, const TensorMap_co
unweightedYData.maxCoeff(&maxIndex);
} else {
generateNormalPDF(static_cast<int>(peakExtentBinNumber));
const auto weightedYData = EigenMap_const(yData.data() + sliceStart, adjPeakExtentBinNumber)
.cwiseProduct(EigenMap_const(m_pdf.data() + startAdj, adjPeakExtentBinNumber));
weightedYData.maxCoeff(&maxIndex);
const auto yDataMap = EigenMap_const(yData.data() + sliceStart, adjPeakExtentBinNumber);
{
std::lock_guard<std::mutex> lock(m_mtx);
const auto weightedYData = yDataMap.cwiseProduct(EigenMap_const(m_pdf.data() + startAdj, adjPeakExtentBinNumber));
weightedYData.maxCoeff(&maxIndex);
}
}
return static_cast<size_t>(maxIndex) + sliceStart;
}

void FindPeaksConvolve::generateNormalPDF(const int peakExtentBinNumber) {
std::lock_guard<std::mutex> lock(m_mtx);
if (m_pdf.size() == 0) {
m_pdf.resize(peakExtentBinNumber);
boost::math::normal_distribution<> dist(0.0,
Expand Down Expand Up @@ -455,7 +459,7 @@ std::string FindPeaksConvolve::populateOutputWorkspaces(
row << m_specNums[i];
for (size_t peak_i{0}; peak_i < m_maxPeakCount; peak_i++) {
if (peak_i < spec.size()) {
auto peak = spec[peak_i];
const auto &peak = spec[peak_i];
row << peak.getAttribute(outputTblName);
} else {
row << std::nan("");
Expand Down
5 changes: 5 additions & 0 deletions Framework/Algorithms/src/FitPeaks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "MantidKernel/ListValidator.h"
#include "MantidKernel/StartsWithValidator.h"
#include "MantidKernel/VectorHelper.h"
#include "MantidKernel/WarningSuppressions.h"

#include "boost/algorithm/string.hpp"
#include "boost/algorithm/string/trim.hpp"
Expand Down Expand Up @@ -2118,6 +2119,8 @@ size_t FitPeaks::histRangeToDataPointCount(size_t iws, const std::pair<double, d
return number_dp;
}

GNU_DIAG_OFF("dangling-reference")

//----------------------------------------------------------------------------------------------
/** Convert a histogram range to vector index boundaries
* @param iws :: histogram index in workspace
Expand Down Expand Up @@ -2172,6 +2175,8 @@ void FitPeaks::getRangeData(size_t iws, const std::pair<double, double> &range,
std::copy(orig_e.begin() + left_index, orig_e.begin() + left_index + num_datapoints, vec_e.begin());
}

GNU_DIAG_ON("dangling-reference")

//----------------------------------------------------------------------------------------------
/** Calculate signal-to-noise ratio in a histogram range
* @param iws :: histogram index in workspace
Expand Down
1 change: 0 additions & 1 deletion Framework/Algorithms/src/GroupWorkspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ std::map<std::string, std::string> GroupWorkspaces::validateInputs() {
std::map<std::string, std::string> results;
const std::vector<std::string> inputWorkspaces = getProperty("InputWorkspaces");
std::string globExpression = getProperty("GlobExpression");
std::string outputWorkspace = getProperty("OutputWorkspace");

for (auto it = globExpression.begin(); it < globExpression.end(); ++it) {
if (*it == '\\') {
Expand Down
2 changes: 1 addition & 1 deletion Framework/Algorithms/src/InterpolatingRebin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ std::map<std::string, std::string> InterpolatingRebin::validateInputs() {
MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace");
std::vector<double> rbParams = getProperty("Params");
try {
std::vector<double> validParams = Rebin::rebinParamsFromInput(rbParams, *inputWS, g_log);
Rebin::rebinParamsFromInput(rbParams, *inputWS, g_log);
} catch (std::exception &err) {
helpMessages["Params"] = err.what();
}
Expand Down
3 changes: 1 addition & 2 deletions Framework/Algorithms/src/SmoothNeighbours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ void SmoothNeighbours::findNeighboursUbiquitous() {
m_progress->resetNumSteps(m_inWS->getNumberHistograms(), 0.2, 0.5);
this->progress(0.2, "Building Neighbour Map");

Instrument_const_sptr inst = m_inWS->getInstrument();
const spec2index_map spec2index = m_inWS->getSpectrumToWorkspaceIndexMap();

// Resize the vector we are setting
Expand Down Expand Up @@ -379,7 +378,7 @@ void SmoothNeighbours::findNeighboursUbiquitous() {
std::vector<weightedNeighbour> neighbours;

// Convert from spectrum numbers to workspace indices
for (auto &specDistance : neighbSpectra) {
for (const auto &specDistance : neighbSpectra) {
specnum_t spec = specDistance.first;

// Use the weighting strategy to calculate the weight.
Expand Down
5 changes: 5 additions & 0 deletions Framework/Algorithms/src/SofQWCentre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "MantidGeometry/Instrument.h"
#include "MantidGeometry/Instrument/DetectorInfo.h"
#include "MantidKernel/PhysicalConstants.h"
#include "MantidKernel/WarningSuppressions.h"

namespace Mantid::Algorithms {

Expand All @@ -27,6 +28,8 @@ using namespace API;
*/
void SofQWCentre::init() { SofQW::createCommonInputProperties(*this); }

GNU_DIAG_OFF("dangling-reference")

void SofQWCentre::exec() {
using namespace Geometry;
using PhysicalConstants::E_mev_toNeutronWavenumberSq;
Expand Down Expand Up @@ -150,6 +153,8 @@ void SofQWCentre::exec() {
prog.report();
}

GNU_DIAG_ON("dangling-reference")

// If the input workspace was a distribution, need to divide by q bin width
if (inputWorkspace->isDistribution())
this->makeDistribution(*outputWorkspace, verticalAxis);
Expand Down
4 changes: 0 additions & 4 deletions Framework/Algorithms/src/Stitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ using namespace Mantid::Kernel;
namespace {
static const std::string INPUT_WORKSPACE_PROPERTY = "InputWorkspaces";
static const std::string REFERENCE_WORKSPACE_PROPERTY = "ReferenceWorkspace";
static const std::string COMBINATION_BEHAVIOUR_PROPERTY = "CombinationBehaviour";
static const std::string SCALE_FACTOR_CALCULATION_PROPERTY = "ScaleFactorCalculation";
static const std::string MANUAL_SCALE_FACTORS_PROPERTY = "ManualScaleFactors";
static const std::string TIE_SCALE_FACTORS_PROPERTY = "TieScaleFactors";
Expand Down Expand Up @@ -241,8 +240,6 @@ void Stitch::init() {
"that is, the one that will not be scaled. If left blank, "
"stitching will be performed left to right in the order of x-axes ascending, "
"no matter the order of workspaces names in the input.");
declareProperty(COMBINATION_BEHAVIOUR_PROPERTY, "Interleave",
std::make_unique<ListValidator<std::string>>(std::array<std::string, 1>{"Interleave"}));
declareProperty(SCALE_FACTOR_CALCULATION_PROPERTY, "MedianOfRatios",
std::make_unique<ListValidator<std::string>>(std::array<std::string, 2>{"MedianOfRatios", "Manual"}));
declareProperty(std::make_unique<ArrayProperty<double>>(MANUAL_SCALE_FACTORS_PROPERTY),
Expand All @@ -264,7 +261,6 @@ void Stitch::init() {
*/
void Stitch::exec() {
const auto referenceName = getPropertyValue(REFERENCE_WORKSPACE_PROPERTY);
const auto combinationBehaviour = getPropertyValue(COMBINATION_BEHAVIOUR_PROPERTY);
const auto scaleFactorCalculation = getPropertyValue(SCALE_FACTOR_CALCULATION_PROPERTY);
const auto inputs = RunCombinationHelper::unWrapGroups(getProperty(INPUT_WORKSPACE_PROPERTY));
MatrixWorkspace_sptr scaleFactorsWorkspace;
Expand Down
3 changes: 1 addition & 2 deletions Framework/Algorithms/src/WeightedMeanOfWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ void WeightedMeanOfWorkspace::exec() {
continue;
auto &y = inputWS->y(i);
auto &e = inputWS->e(i);
double weight = 0.0;
for (std::size_t j = 0; j < y.size(); ++j) {
if (std::isfinite(y[j]) && std::isfinite(e[j])) {
weight = 1.0 / (e[j] * e[j]);
double weight = 1.0 / (e[j] * e[j]);
averageValue += (y[j] * weight);
weightSum += weight;
}
Expand Down
2 changes: 1 addition & 1 deletion Framework/Algorithms/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-maybe-uninitialized)
add_compile_options(-Wno-uninitialized)
endif()

if(CXXTEST_FOUND)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "MantidFrameworkTestHelpers/WorkspaceCreationHelper.h"
#include "MantidHistogramData/LinearGenerator.h"
#include "MantidIndexing/IndexInfo.h"
#include "MantidKernel/WarningSuppressions.h"

using namespace Mantid;
using namespace Mantid::API;
Expand Down Expand Up @@ -189,6 +190,8 @@ class CalculateCarpenterSampleCorrectionTest : public CxxTest::TestSuite {
AnalysisDataService::Instance().remove("TestOutputWS");
}

GNU_DIAG_OFF("dangling-reference")

void testCalculationEvent() {
const std::string outName("CalculateCarpenterSampleCorrectionEventOutput");

Expand Down Expand Up @@ -255,6 +258,8 @@ class CalculateCarpenterSampleCorrectionTest : public CxxTest::TestSuite {
AnalysisDataService::Instance().remove(outName);
}

GNU_DIAG_ON("dangling-reference")

private:
Mantid::Algorithms::CalculateCarpenterSampleCorrection algorithm;
};
5 changes: 5 additions & 0 deletions Framework/Algorithms/test/CarpenterSampleCorrectionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "MantidFrameworkTestHelpers/WorkspaceCreationHelper.h"
#include "MantidHistogramData/LinearGenerator.h"
#include "MantidIndexing/IndexInfo.h"
#include "MantidKernel/WarningSuppressions.h"

using namespace Mantid;
using namespace Mantid::API;
Expand Down Expand Up @@ -64,6 +65,8 @@ class CarpenterSampleCorrectionTest : public CxxTest::TestSuite {
TS_ASSERT(dynamic_cast<PropertyWithValue<double> *>(props[5]));
}

GNU_DIAG_OFF("dangling-reference")

void testCalculationHist() {
using namespace Mantid::HistogramData;
auto wksp = DataObjects::create<DataObjects::Workspace2D>(
Expand Down Expand Up @@ -154,6 +157,8 @@ class CarpenterSampleCorrectionTest : public CxxTest::TestSuite {
TS_ASSERT_LESS_THAN(y_actual[i], 6.66480);
}

GNU_DIAG_ON("dangling-reference")

// cleanup
AnalysisDataService::Instance().remove(outName);
}
Expand Down
9 changes: 6 additions & 3 deletions Framework/Algorithms/test/FindPeaksConvolveTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/FrameworkManager.h"
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidAlgorithms/FindPeaksConvolve.h"
Expand Down Expand Up @@ -69,11 +70,13 @@ class FindPeaksConvolveTest : public CxxTest::TestSuite {
static FindPeaksConvolveTest *createSuite() { return new FindPeaksConvolveTest(); }
static void destroySuite(FindPeaksConvolveTest *suite) { delete suite; }

FindPeaksConvolveTest() { Mantid::API::FrameworkManager::Instance(); }

void setUp() override {
// Load data file into ADS once
loadNexusProcessed("ENGINX_277208_focused_bank_2.nxs", INPUT_TEST_WS_NAME);
loadNexusProcessed("VesuvioCalibSpec177.nxs", INPUT_TEST_WS_NAME + "_noisy");
loadNexusProcessed("focussed.nxs", INPUT_TEST_WS_NAME + "_focussed");
TS_ASSERT_THROWS_NOTHING(loadNexusProcessed("ENGINX_277208_focused_bank_2.nxs", INPUT_TEST_WS_NAME));
TS_ASSERT_THROWS_NOTHING(loadNexusProcessed("VesuvioCalibSpec177.nxs", INPUT_TEST_WS_NAME + "_noisy"));
TS_ASSERT_THROWS_NOTHING(loadNexusProcessed("focussed.nxs", INPUT_TEST_WS_NAME + "_focussed"));
}

void test_exec() {
Expand Down
3 changes: 3 additions & 0 deletions Framework/Algorithms/test/FitPeaksTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "MantidFrameworkTestHelpers/WorkspaceCreationHelper.h"
#include "MantidKernel/Logger.h"
#include "MantidKernel/UnitFactory.h"
#include "MantidKernel/WarningSuppressions.h"

using Mantid::Algorithms::FitPeaks;

Expand All @@ -34,6 +35,8 @@ using Mantid::HistogramData::Counts;
using Mantid::HistogramData::CountStandardDeviations;
using Mantid::HistogramData::Points;

GNU_DIAG_OFF("dangling-reference")

namespace {
/// static Logger definition
Logger g_log("FitPeaksTest");
Expand Down
5 changes: 5 additions & 0 deletions Framework/Algorithms/test/NormaliseToMonitorTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "MantidHistogramData/LinearGenerator.h"
#include "MantidIndexing/IndexInfo.h"
#include "MantidKernel/UnitFactory.h"
#include "MantidKernel/WarningSuppressions.h"

using namespace Mantid;
using namespace Mantid::Kernel;
Expand Down Expand Up @@ -404,6 +405,8 @@ class NormaliseToMonitorTest : public CxxTest::TestSuite {
TS_ASSERT(alg.isExecuted())
}

GNU_DIAG_OFF("dangling-reference")

void test_with_scanning_workspace_bin_by_bin() {
auto testWS = makeTestDetectorScanWorkspace();

Expand Down Expand Up @@ -504,6 +507,8 @@ class NormaliseToMonitorTest : public CxxTest::TestSuite {
}
}

GNU_DIAG_ON("dangling-reference")

private:
MatrixWorkspace_sptr makeTestDetectorScanWorkspace() {
const size_t N_DET = 10;
Expand Down
2 changes: 1 addition & 1 deletion Framework/Beamline/src/ComponentInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void ComponentInfo::doScaleComponent(const std::pair<size_t, size_t> &index, con
const size_t offsetIndex = compOffsetIndex(subIndex);
Eigen::Vector3d oldPos = position({subIndex, timeIndex});
Eigen::Vector3d newPos = scalingMatrix * oldPos + (Eigen::Matrix3d::Identity() - scalingMatrix) * compPos;
m_positions.access()[linearIndex({offsetIndex, timeIndex})] = newPos;
m_positions.access()[linearIndex({offsetIndex, timeIndex})] = std::move(newPos);
}
}

Expand Down
1 change: 0 additions & 1 deletion Framework/Crystal/src/GoniometerAnglesFromPhiRotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ void GoniometerAnglesFromPhiRotation::exec() {
double deg, ax1, ax2, ax3;
Q1.getAngleAxis(deg, ax1, ax2, ax3);
if (dphi * deg < 0) {
deg = -deg;
ax1 = -ax1;
ax2 = -ax2;
ax3 = -ax3;
Expand Down
Loading

0 comments on commit a54c844

Please sign in to comment.