Commit 7e592d6e authored by Tom Perkins's avatar Tom Perkins
Browse files

Enable all StatisticTypes in conversion to double

Median was missing, and Mean was implemented as TimeAveragedMean:
correct this and implement all members of the enum.

re #17087
parent 6a0ed1c7
......@@ -49,16 +49,30 @@ template <typename T>
bool convertTimeSeriesToDouble(const Property *property, double &value,
const Math::StatisticType &function) {
if (const auto *log = dynamic_cast<const TimeSeriesProperty<T> *>(property)) {
if (function == Math::Mean) {
switch (function) {
case Math::TimeAveragedMean:
value = static_cast<double>(log->timeAverageValue());
} else if (function == Math::FirstValue) {
break;
case Math::FirstValue:
value = static_cast<double>(log->firstValue());
} else if (function == Math::Minimum) {
value = static_cast<double>(log->minValue());
} else if (function == Math::Maximum) {
value = static_cast<double>(log->maxValue());
} else { // default
break;
case Math::LastValue:
value = static_cast<double>(log->lastValue());
break;
case Math::Maximum:
value = static_cast<double>(log->maxValue());
break;
case Math::Minimum:
value = static_cast<double>(log->minValue());
break;
case Math::Mean:
value = log->getStatistics().mean;
break;
case Math::Median:
value = log->getStatistics().median;
break;
default: // should not happen
throw std::invalid_argument("Statistic type not recognised/supported");
}
return true;
} else {
......
......@@ -487,9 +487,9 @@ private:
LogManager runInfo;
const std::string name = "T_series";
addTestTimeSeries<T>(runInfo, name);
const double expectedValue(24.0);
const double expectedValue(13.0);
TS_ASSERT_DELTA(
runInfo.getPropertyAsSingleValue(name, Mantid::Kernel::Math::LastValue),
runInfo.getPropertyAsSingleValue(name, Mantid::Kernel::Math::Mean),
expectedValue, 1e-12);
}
};
......
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