Commit fea2eee4 authored by Whitfield, Ross's avatar Whitfield, Ross
Browse files

Change some method from returning NaN to throw

parent 217b7972
......@@ -48,12 +48,6 @@ public:
#if defined(_MSC_VER) && _MSC_VER <= 1910
BasePeak(BasePeak &&) = default;
BasePeak &operator=(BasePeak &&) = default;
#elif ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ <= 8))
// The noexcept default declaration was fixed in GCC 4.9.0
// so for versions 4.8.x and below use default only
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53903
BasePeak(BasePeak &&) = default;
BasePeak &operator=(BasePeak &&) = default;
#else
BasePeak(BasePeak &&) noexcept = default;
BasePeak &operator=(BasePeak &&) noexcept = default;
......
......@@ -50,12 +50,6 @@ public:
#if defined(_MSC_VER) && _MSC_VER <= 1910
LeanPeak(LeanPeak &&) = default;
LeanPeak &operator=(LeanPeak &&) = default;
#elif ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ <= 8))
// The noexcept default declaration was fixed in GCC 4.9.0
// so for versions 4.8.x and below use default only
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53903
LeanPeak(LeanPeak &&) = default;
LeanPeak &operator=(LeanPeak &&) = default;
#else
LeanPeak(LeanPeak &&) noexcept = default;
LeanPeak &operator=(LeanPeak &&) noexcept = default;
......
......@@ -67,12 +67,6 @@ public:
#if defined(_MSC_VER) && _MSC_VER <= 1910
Peak(Peak &&) = default;
Peak &operator=(Peak &&) = default;
#elif ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ <= 8))
// The noexcept default declaration was fixed in GCC 4.9.0
// so for versions 4.8.x and below use default only
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53903
Peak(Peak &&) = default;
Peak &operator=(Peak &&) = default;
#else
Peak(Peak &&) noexcept = default;
Peak &operator=(Peak &&) noexcept = default;
......
......@@ -217,9 +217,7 @@ void BasePeak::setHKL(double H, double K, double L) {
* @param HKL :: vector with x,y,z -> h,k,l
*/
void BasePeak::setHKL(const Mantid::Kernel::V3D &HKL) {
m_H = HKL.X();
m_K = HKL.Y();
m_L = HKL.Z();
this->setHKL(HKL.X(), HKL.Y(), HKL.Z());
}
/** Set int HKL
......@@ -250,7 +248,7 @@ double BasePeak::getSigmaIntensity() const { return m_sigmaIntensity; }
/** Return the peak intensity divided by the error in the intensity */
double BasePeak::getIntensityOverSigma() const {
const auto result = m_intensity / m_sigmaIntensity;
return (std::isinf(result)) ? 0.0 : result;
return (std::isfinite(result)) ? result : 0.0;
}
/** Set the integrated peak intensity
......
......@@ -242,13 +242,13 @@ Mantid::Kernel::V3D LeanPeak::getSamplePos() const {
// -------------------------------------------------------------------------------------
/** Return the L1 flight path length (source to sample), in meters. */
double LeanPeak::getL1() const {
return std::numeric_limits<double>::quiet_NaN();
throw Exception::NotImplementedError("LeanPeak has no detector information");
}
// -------------------------------------------------------------------------------------
/** Return the L2 flight path length (sample to detector), in meters. */
double LeanPeak::getL2() const {
return std::numeric_limits<double>::quiet_NaN();
throw Exception::NotImplementedError("LeanPeak has no detector information");
}
/**
......@@ -292,7 +292,7 @@ bool LeanPeak::findDetector(const InstrumentRayTracer &) {
Forwarding function. Exposes the detector position directly.
*/
Mantid::Kernel::V3D LeanPeak::getDetectorPositionNoCheck() const {
return getDetector()->getPos();
throw Exception::NotImplementedError("LeanPeak has no detector information");
}
/**
......@@ -300,12 +300,7 @@ Mantid::Kernel::V3D LeanPeak::getDetectorPositionNoCheck() const {
the detector is not null before accessing its position. Throws if null.
*/
Mantid::Kernel::V3D LeanPeak::getDetectorPosition() const {
auto det = getDetector();
if (det == nullptr) {
throw Mantid::Kernel::Exception::NullPointerException("LeanPeak",
"Detector");
}
return getDetector()->getPos();
throw Exception::NotImplementedError("LeanPeak has no detector information");
}
Mantid::Kernel::Logger LeanPeak::g_log("PeakLogger");
......
......@@ -49,8 +49,8 @@ public:
TS_ASSERT(std::isnan(p.getTOF()))
TS_ASSERT(std::isnan(p.getScattering()))
TS_ASSERT(std::isnan(p.getAzimuthal()))
TS_ASSERT(std::isnan(p.getL1()))
TS_ASSERT(std::isnan(p.getL2()))
TS_ASSERT_THROWS(p.getL1(), const Exception::NotImplementedError &)
TS_ASSERT_THROWS(p.getL2(), const Exception::NotImplementedError &)
}
void test_Qsample_constructor() {
......@@ -280,5 +280,10 @@ public:
TS_ASSERT_EQUALS(leanpeak.getBinCount(), peak.getBinCount());
TS_ASSERT_EQUALS(leanpeak.getBinCount(), 90);
TS_ASSERT_THROWS(leanpeak.getDetector(),
const Exception::NotImplementedError &)
TS_ASSERT_THROWS(leanpeak.getInstrument(),
const Exception::NotImplementedError &)
}
};
Markdown is supported
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