Commit a6f561ef authored by Samuel Jackson's avatar Samuel Jackson
Browse files

Refs #20441 Fix comments from code review

parent b1e0aade
...@@ -796,9 +796,8 @@ double Peak::getSigmaIntensity() const { return m_sigmaIntensity; } ...@@ -796,9 +796,8 @@ double Peak::getSigmaIntensity() const { return m_sigmaIntensity; }
/** Return the peak intensity divided by the error in the intensity */ /** Return the peak intensity divided by the error in the intensity */
double Peak::getIntensityOverSigma() const { double Peak::getIntensityOverSigma() const {
if (m_sigmaIntensity == 0) const auto result = m_intensity / m_sigmaIntensity;
return 0; return (std::isinf(result)) ? 0.0 : result;
return m_intensity / m_sigmaIntensity;
} }
/** Set the integrated peak intensity /** Set the integrated peak intensity
......
...@@ -572,14 +572,16 @@ public: ...@@ -572,14 +572,16 @@ public:
void test_get_intensity_over_sigma_empty_sigma() { void test_get_intensity_over_sigma_empty_sigma() {
const int detectorId = 19999; const int detectorId = 19999;
const double wavelength = 2; const double wavelength = 2;
const double intensity{0}; const double intensity{10};
const double sigma{0}; const double sigma{0};
Peak p(inst, detectorId, wavelength); Peak p(inst, detectorId, wavelength);
p.setIntensity(intensity); p.setIntensity(intensity);
p.setSigmaIntensity(sigma); p.setSigmaIntensity(sigma);
TS_ASSERT_DELTA(p.getIntensityOverSigma(), 0, 1e-10); const double expectedResult {0.0};
const double tolerance {1e-10};
TS_ASSERT_DELTA(p.getIntensityOverSigma(), expectedResult, tolerance);
} }
void test_get_energy() { void test_get_energy() {
......
...@@ -174,27 +174,28 @@ QPeaksTableModel::QPeaksTableModel( ...@@ -174,27 +174,28 @@ QPeaksTableModel::QPeaksTableModel(
}, },
[](const IPeak &peak) { return QVariant(peak.getRow()); }, [](const IPeak &peak) { return QVariant(peak.getRow()); },
[](const IPeak &peak) { return QVariant(peak.getCol()); }, [](const IPeak &peak) { return QVariant(peak.getCol()); },
[&v3dAsString](const IPeak &peak) { [](const IPeak &peak) {
return v3dAsString(peak.getQLabFrame()); return QVariant(peak.getQLabFrame().norm());
}, },
[&v3dAsString](const IPeak &peak) { [](const IPeak &peak) {
return v3dAsString(peak.getQSampleFrame()); return QVariant(peak.getQSampleFrame().norm());
}, },
}; };
const auto hklPrec = m_hklPrec;
// Mapping member functions of the Peak object to a column index with // Mapping member functions of the Peak object to a column index with
// formatting for displaying data to the user // formatting for displaying data to the user
m_formattedValueLookup = { m_formattedValueLookup = {
[](const IPeak &peak) { return QString::number(peak.getRunNumber()); }, [](const IPeak &peak) { return QString::number(peak.getRunNumber()); },
[](const IPeak &peak) { return QString::number(peak.getDetectorID()); }, [](const IPeak &peak) { return QString::number(peak.getDetectorID()); },
[this](const IPeak &peak) { [&hklPrec](const IPeak &peak) {
return QString::number(peak.getH(), 'f', m_hklPrec); return QString::number(peak.getH(), 'f', hklPrec);
}, },
[this](const IPeak &peak) { [&hklPrec](const IPeak &peak) {
return QString::number(peak.getK(), 'f', m_hklPrec); return QString::number(peak.getK(), 'f', hklPrec);
}, },
[this](const IPeak &peak) { [&hklPrec](const IPeak &peak) {
return QString::number(peak.getL(), 'f', m_hklPrec); return QString::number(peak.getL(), 'f', hklPrec);
}, },
[](const IPeak &peak) { [](const IPeak &peak) {
return QString::number(peak.getWavelength(), 'f', 4); return QString::number(peak.getWavelength(), 'f', 4);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment