Skip to content

Commit fdbec10

Browse files
peterfpetersonjclarkeSTFCpre-commit-ci[bot]jhaigh0MialLewis
authored
Various for fixes from main (#39257)
* Several Cppcheck fixes * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.6 → v0.11.7](astral-sh/ruff-pre-commit@v0.11.6...v0.11.7) * specify python install to fix linux standalone launch change pystack message to be warning not error simplify startup test now that workbench calls launch_mantidworkbench switch to specifying python install using sys.executable * fix error on sample log plot resize add release note --------- Co-authored-by: James Clarke <james.clarke@stfc.ac.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jonathan Haigh <jonathan.haigh@stfc.ac.uk> Co-authored-by: MialLewis <95620982+MialLewis@users.noreply.github.com>
1 parent abeed9f commit fdbec10

File tree

22 files changed

+90
-150
lines changed

22 files changed

+90
-150
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ repos:
5959
)$
6060
6161
- repo: https://github.com/astral-sh/ruff-pre-commit
62-
rev: v0.11.4
62+
rev: v0.11.7
6363
# ruff must appear before black in the list of hooks
6464
hooks:
6565
- id: ruff

Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void runCrossEntropy(CostFunctions::CostFuncFitting &costFunction, const std::ve
211211
// Initialise the normal distribution parameters (mean and sigma for each
212212
// function parameter).
213213
std::vector<std::pair<double, double>> distributionParams;
214-
for (auto &range : ranges) {
214+
for (const auto &range : ranges) {
215215
auto mean = (range.first + range.second) / 2;
216216
auto sigma = std::fabs(range.first - range.second) / 2;
217217
distributionParams.emplace_back(mean, sigma);
@@ -257,7 +257,7 @@ void runCrossEntropy(CostFunctions::CostFuncFitting &costFunction, const std::ve
257257
EigenVector means(nParams);
258258
EigenVector variances(nParams);
259259
for (size_t isam = 0; isam < nSelection; ++isam) {
260-
auto &paramSet = sampleSets[isam];
260+
const auto &paramSet = sampleSets[isam];
261261
for (size_t i = 0; i < nParams; ++i) {
262262
auto p = paramSet.second[i];
263263
means[i] += p;
@@ -359,7 +359,7 @@ void EstimateFitParameters::execConcrete() {
359359
func->fix(i);
360360
continue;
361361
}
362-
auto boundary = dynamic_cast<Constraints::BoundaryConstraint *>(constraint);
362+
const auto *boundary = dynamic_cast<Constraints::BoundaryConstraint *>(constraint);
363363
if (!boundary) {
364364
throw std::runtime_error("Parameter " + func->parameterName(i) + " must have a boundary constraint. ");
365365
}
@@ -386,7 +386,7 @@ void EstimateFitParameters::execConcrete() {
386386

387387
if (getPropertyValue("Type") == "Monte Carlo") {
388388
int nOutput = getProperty("NOutputs");
389-
auto outputWorkspaceProp = getPointerToProperty("OutputWorkspace");
389+
const auto *outputWorkspaceProp = getPointerToProperty("OutputWorkspace");
390390
if (outputWorkspaceProp->isDefault() || nOutput <= 0) {
391391
nOutput = 1;
392392
}
@@ -405,7 +405,7 @@ void EstimateFitParameters::execConcrete() {
405405
if (m_function->isActive(i)) {
406406
TableRow row = table->appendRow();
407407
row << m_function->parameterName(i);
408-
for (auto &j : output) {
408+
for (const auto &j : output) {
409409
row << j[ia];
410410
}
411411
++ia;

Framework/CurveFitting/src/Functions/BivariateNormal.cpp

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ void BivariateNormal::function1D(double *out, const double *xValues, const size_
8787
out[i] = 0.0;
8888
return;
8989
}
90-
double coefNorm, expCoeffx2, expCoeffy2, expCoeffxy, Varxx, Varxy, Varyy;
91-
int NCells;
90+
double coefficientNorm, exponentialCoeffx2, exponentialCoeffy2, exponentialCoeffxy, Varxx, Varxy, Varyy;
91+
int numberOfCells;
9292
bool isNaNs;
9393

9494
API::MatrixWorkspace_const_sptr ws = getMatrixWorkspace();
@@ -103,7 +103,8 @@ void BivariateNormal::function1D(double *out, const double *xValues, const size_
103103

104104
getConstraint(IBACK)->setPenaltyFactor(K * 3000);
105105

106-
double badParams = initCoeff(D, X, Y, coefNorm, expCoeffx2, expCoeffy2, expCoeffxy, NCells, Varxx, Varxy, Varyy);
106+
double badParams = initCoeff(D, X, Y, coefficientNorm, exponentialCoeffx2, exponentialCoeffy2, exponentialCoeffxy,
107+
numberOfCells, Varxx, Varxy, Varyy);
107108

108109
std::ostringstream inf;
109110
inf << "F Parameters=";
@@ -113,7 +114,7 @@ void BivariateNormal::function1D(double *out, const double *xValues, const size_
113114
inf << "," << Varxx << "," << Varyy << "," << Varxy;
114115
inf << '\n';
115116

116-
NCells = std::min<int>(static_cast<int>(nData), NCells);
117+
numberOfCells = std::min<int>(static_cast<int>(nData), numberOfCells);
117118

118119
double Background = getParameter(IBACK);
119120
double Intensity = getParameter(ITINTENS);
@@ -127,7 +128,7 @@ void BivariateNormal::function1D(double *out, const double *xValues, const size_
127128

128129
// double penalty =0;
129130

130-
for (int i = 0; i < NCells; i++) {
131+
for (int i = 0; i < numberOfCells; i++) {
131132
// double pen =0;
132133
if (badParams > 0)
133134
out[x] = badParams;
@@ -136,8 +137,9 @@ void BivariateNormal::function1D(double *out, const double *xValues, const size_
136137
else {
137138
double dx = X[i] - Xmean;
138139
double dy = Y[i] - Ymean;
139-
out[x] =
140-
Background + coefNorm * Intensity * exp(expCoeffx2 * dx * dx + expCoeffxy * dx * dy + expCoeffy2 * dy * dy);
140+
out[x] = Background +
141+
coefficientNorm * Intensity *
142+
exp(exponentialCoeffx2 * dx * dx + exponentialCoeffxy * dx * dy + exponentialCoeffy2 * dy * dy);
141143
out[x] = out[x] + DDD;
142144

143145
if (out[x] != out[x]) {
@@ -177,7 +179,7 @@ void BivariateNormal::functionDeriv1D(API::Jacobian *out, const double *xValues,
177179
std::vector<double> outf(nData, 0.0);
178180
function1D(outf.data(), xValues, nData);
179181

180-
double uu = LastParams[IVXX] * LastParams[IVYY] - LastParams[IVXY] * LastParams[IVXY];
182+
double paramUU = LastParams[IVXX] * LastParams[IVYY] - LastParams[IVXY] * LastParams[IVXY];
181183
/* if( uu <=0)
182184
{
183185
penDeriv = -2*uu;
@@ -206,8 +208,8 @@ void BivariateNormal::functionDeriv1D(API::Jacobian *out, const double *xValues,
206208

207209
double coefExp = coefNorm * LastParams[ITINTENS];
208210

209-
double coefxy = LastParams[IVXY] / uu;
210-
double coefx2 = -LastParams[IVYY] / 2 / uu;
211+
double coefxy = LastParams[IVXY] / paramUU;
212+
double coefx2 = -LastParams[IVYY] / 2 / paramUU;
211213

212214
if (penaltyDeriv <= 0)
213215
out->set(x, IXMEAN,
@@ -220,7 +222,7 @@ void BivariateNormal::functionDeriv1D(API::Jacobian *out, const double *xValues,
220222

221223
coefExp = coefNorm * LastParams[ITINTENS];
222224

223-
double coefy2 = -LastParams[IVXX] / 2 / uu;
225+
double coefy2 = -LastParams[IVXX] / 2 / paramUU;
224226

225227
if (penaltyDeriv <= 0)
226228
out->set(x, IYMEAN,
@@ -236,17 +238,17 @@ void BivariateNormal::functionDeriv1D(API::Jacobian *out, const double *xValues,
236238
M = 10;
237239
coefExp = coefNorm * LastParams[ITINTENS];
238240

239-
double C = -LastParams[IVYY] / 2 / uu;
241+
double C = -LastParams[IVYY] / 2 / paramUU;
240242

241243
double SIVXX;
242244
if (penaltyDeriv <= 0)
243245
SIVXX = coefExp * expVals[x] *
244246
(C +
245-
-LastParams[IVYY] / uu *
247+
-LastParams[IVYY] / paramUU *
246248
(coefx2 * (c - LastParams[IXMEAN]) * (c - LastParams[IXMEAN]) +
247249
coefxy * (r - LastParams[IYMEAN]) * (c - LastParams[IXMEAN]) +
248250
coefy2 * (r - LastParams[IYMEAN]) * (r - LastParams[IYMEAN])) -
249-
(r - LastParams[IYMEAN]) * (r - LastParams[IYMEAN]) / 2 / uu);
251+
(r - LastParams[IYMEAN]) * (r - LastParams[IYMEAN]) / 2 / paramUU);
250252
else if (LastParams[IVXX] < .01)
251253
SIVXX = -M;
252254
else
@@ -258,17 +260,17 @@ void BivariateNormal::functionDeriv1D(API::Jacobian *out, const double *xValues,
258260
SIVXX = 0;
259261
coefExp = coefNorm * LastParams[ITINTENS];
260262

261-
C = -LastParams[IVXX] / 2 / uu;
263+
C = -LastParams[IVXX] / 2 / paramUU;
262264

263265
double SIVYY;
264266
if (penaltyDeriv <= 0)
265267
SIVYY = coefExp * expVals[x] *
266268
(C +
267-
-LastParams[IVXX] / uu *
269+
-LastParams[IVXX] / paramUU *
268270
(coefx2 * (c - LastParams[IXMEAN]) * (c - LastParams[IXMEAN]) +
269271
coefxy * (r - LastParams[IYMEAN]) * (c - LastParams[IXMEAN]) +
270272
coefy2 * (r - LastParams[IYMEAN]) * (r - LastParams[IYMEAN])) -
271-
(c - LastParams[IXMEAN]) * (c - LastParams[IXMEAN]) / 2 / uu);
273+
(c - LastParams[IXMEAN]) * (c - LastParams[IXMEAN]) / 2 / paramUU);
272274

273275
else if (LastParams[IVYY] < .01)
274276
SIVYY = -M;
@@ -282,19 +284,19 @@ void BivariateNormal::functionDeriv1D(API::Jacobian *out, const double *xValues,
282284
SIVYY = 0;
283285
coefExp = coefNorm * LastParams[ITINTENS];
284286

285-
C = LastParams[IVXY] / uu;
287+
C = LastParams[IVXY] / paramUU;
286288

287289
double SIVXY;
288290
if (penaltyDeriv <= 0)
289291
SIVXY = coefExp * expVals[x] *
290292
(C +
291-
2 * LastParams[IVXY] / uu *
293+
2 * LastParams[IVXY] / paramUU *
292294
(coefx2 * (c - LastParams[IXMEAN]) * (c - LastParams[IXMEAN]) +
293295
coefxy * (r - LastParams[IYMEAN]) * (c - LastParams[IXMEAN]) +
294296
coefy2 * (r - LastParams[IYMEAN]) * (r - LastParams[IYMEAN])) +
295-
(r - LastParams[IYMEAN]) * (c - LastParams[IXMEAN]) / uu);
297+
(r - LastParams[IYMEAN]) * (c - LastParams[IXMEAN]) / paramUU);
296298

297-
else if (uu < 0)
299+
else if (paramUU < 0)
298300
SIVXY = 2 * LastParams[IVXY];
299301
else
300302
SIVXY = 0;
@@ -468,16 +470,15 @@ double BivariateNormal::initCommon() {
468470
addConstraint(std::make_unique<BoundaryConstraint>(this, "Intensity", 0, maxIntensity));
469471
}
470472

471-
double minMeany = MinY * .9 + .1 * MaxY;
472-
double maxMeany = MinY * .1 + .9 * MaxY;
473-
474473
if (getConstraint(3) == nullptr) {
474+
double minMeany = MinY * .9 + .1 * MaxY;
475+
double maxMeany = MinY * .1 + .9 * MaxY;
475476
addConstraint(std::make_unique<BoundaryConstraint>(this, "Mrow", minMeany, maxMeany));
476477
}
477478

478-
double minMeanx = MinX * .9 + .1 * MaxX;
479-
double maxMeanx = MinX * .1 + .9 * MaxX;
480479
if (getConstraint(2) == nullptr) {
480+
double minMeanx = MinX * .9 + .1 * MaxX;
481+
double maxMeanx = MinX * .1 + .9 * MaxX;
481482
addConstraint(std::make_unique<BoundaryConstraint>(this, "Mcol", minMeanx, maxMeanx));
482483
}
483484

@@ -609,18 +610,19 @@ double BivariateNormal::initCoeff(const HistogramY &D, const HistogramY &X, cons
609610
Varxy = getParameter(IVXY);
610611
}
611612

612-
double uu = Varxx * Varyy - Varxy * Varxy;
613+
double paramUU = Varxx * Varyy - Varxy * Varxy;
613614
double penalty;
614615
if (zeroDenom)
615616
penalty = 200;
616617
else
617-
penalty = std::max<double>(0, -Varxx + .01) + std::max<double>(0, -Varyy + .01) + std::max<double>(0, -uu + .01);
618+
penalty =
619+
std::max<double>(0, -Varxx + .01) + std::max<double>(0, -Varyy + .01) + std::max<double>(0, -paramUU + .01);
618620

619-
if (fabs(uu) < .01) {
620-
if (uu < 0)
621-
uu = -.01;
621+
if (fabs(paramUU) < .01) {
622+
if (paramUU < 0)
623+
paramUU = -.01;
622624
else
623-
uu = .01;
625+
paramUU = .01;
624626
}
625627

626628
NCells = static_cast<int>(std::min<size_t>(D.size(), std::min<size_t>(X.size(), Y.size())));
@@ -631,11 +633,11 @@ double BivariateNormal::initCoeff(const HistogramY &D, const HistogramY &X, cons
631633
Varxy = 0;
632634
return penalty;
633635
}
634-
coefNorm = .5 / M_PI / sqrt(fabs(uu));
636+
coefNorm = .5 / M_PI / sqrt(fabs(paramUU));
635637

636-
expCoeffx2 = -fabs(Varyy) / 2 / fabs(uu);
637-
expCoeffxy = Varxy / uu;
638-
expCoeffy2 = -fabs(Varxx) / 2 / fabs(uu);
638+
expCoeffx2 = -fabs(Varyy) / 2 / fabs(paramUU);
639+
expCoeffxy = Varxy / paramUU;
640+
expCoeffy2 = -fabs(Varxx) / 2 / fabs(paramUU);
639641

640642
if (nParams() < 5)
641643
penalty *= 10;

Framework/DataHandling/inc/MantidDataHandling/CheckMantidVersion.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ namespace DataHandling {
1717
*/
1818
class MANTID_DATAHANDLING_DLL CheckMantidVersion : public API::Algorithm {
1919
public:
20-
virtual ~CheckMantidVersion() = default;
2120
const std::string name() const override;
2221
int version() const override;
2322
const std::string category() const override;

Framework/DataHandling/inc/MantidDataHandling/CreatePolarizationEfficienciesBase.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class MANTID_DATAHANDLING_DLL CreatePolarizationEfficienciesBase : public API::A
2727
const std::string category() const override;
2828

2929
protected:
30-
~CreatePolarizationEfficienciesBase() = default;
3130
void initOutputWorkspace();
3231
std::vector<std::string> getNonDefaultProperties(std::vector<std::string> const &props) const;
3332

Framework/DataHandling/inc/MantidDataHandling/DownloadInstrument.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ namespace DataHandling {
2323
class MANTID_DATAHANDLING_DLL DownloadInstrument : public API::Algorithm {
2424
public:
2525
DownloadInstrument();
26-
virtual ~DownloadInstrument() = default;
27-
2826
const std::string name() const override;
2927
int version() const override;
3028
const std::vector<std::string> seeAlso() const override { return {"LoadInstrument", "UpdateScriptRepository"}; }

Framework/DataHandling/inc/MantidDataHandling/FindDetectorsPar.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ class DetParameters;
121121

122122
class MANTID_DATAHANDLING_DLL FindDetectorsPar : public API::Algorithm {
123123
public:
124-
virtual ~FindDetectorsPar() = default;
125124
/// Algorithm's name for identification overriding a virtual method
126125
const std::string name() const override { return "FindDetectorsPar"; };
127126
/// Summary of algorithms purpose

Framework/DataHandling/inc/MantidDataHandling/ISISJournal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "MantidKernel/InternetHelper.h"
1212

1313
#include <Poco/AutoPtr.h>
14+
#include <Poco/DOM/Document.h>
1415
#include <map>
1516
#include <memory>
1617
#include <string>
@@ -32,8 +33,6 @@ class MANTID_DATAHANDLING_DLL ISISJournal : public API::IJournal {
3233
public:
3334
ISISJournal(std::string const &instrument, std::string const &cycle,
3435
std::unique_ptr<Kernel::InternetHelper> internetHelper = std::make_unique<Kernel::InternetHelper>());
35-
virtual ~ISISJournal();
36-
3736
ISISJournal(ISISJournal const &rhs) = delete;
3837
ISISJournal(ISISJournal &&rhs);
3938
ISISJournal const &operator=(ISISJournal const &rhs) = delete;

Framework/DataHandling/inc/MantidDataHandling/LoadDNSEvent.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class MANTID_DATAHANDLING_DLL LoadDNSEvent : public API::IFileLoader<Kernel::Fil
4141

4242
// Algorithm's version for identification
4343
int version() const override { return 1; }
44-
const std::vector<std::string> seeAlso() const override { return {}; }
4544
// Algorithm's category for identification
4645
const std::string category() const override { return "DataHandling"; }
4746
// Returns a confidence value that this algorithm can load a file

Framework/DataHandling/src/ISISJournal.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ ISISJournal::ISISJournal(std::string const &instrument, std::string const &cycle
243243
: m_internetHelper(std::move(internetHelper)), m_runsFileURL(constructURL(instrument, cycle)),
244244
m_indexFileURL(constructURL(instrument, INDEX_FILE_NAME)) {}
245245

246-
ISISJournal::~ISISJournal() = default;
247-
248246
ISISJournal::ISISJournal(ISISJournal &&rhs) = default;
249247

250248
ISISJournal &ISISJournal::operator=(ISISJournal &&rhs) = default;

0 commit comments

Comments
 (0)