Commit b2db1e98 authored by Nick Draper's avatar Nick Draper
Browse files

clang format

parent 47336152
......@@ -191,7 +191,8 @@ public:
// returns true if the log has a matching invalid values log filter
bool hasInvalidValuesFilter(const std::string logName) const;
// returns the invalid values log if the log has a matching invalid values log filter
// returns the invalid values log if the log has a matching invalid values log
// filter
Kernel::TimeSeriesProperty<bool> *
getInvalidValuesFilter(const std::string logName) const;
......
......@@ -552,8 +552,8 @@ void LogManager::loadNexus(::NeXus::File *file,
*/
void LogManager::clearLogs() { m_manager->clear(); }
/// Gets the correct log name for the matching invalid values log for a given log
/// name
/// Gets the correct log name for the matching invalid values log for a given
/// log name
std::string
LogManager::getInvalidValuesFilterLogName(const std::string logName) {
return PropertyManager::getInvalidValuesFilterLogName(logName);
......@@ -573,9 +573,8 @@ LogManager::getInvalidValuesFilter(const std::string logName) const {
if (auto tsp = dynamic_cast<TimeSeriesProperty<bool> *>(log)) {
return tsp;
}
}
catch(Exception::NotFoundError &) {
//do nothing, just drop through tto the return line below
} catch (Exception::NotFoundError &) {
// do nothing, just drop through tto the return line below
}
return nullptr;
}
......
......@@ -54,7 +54,6 @@ private:
std::string m_value = "Nothing";
};
void addTestTimeSeriesFilter(LogManager &run, const std::string &name) {
auto timeSeries = new TimeSeriesProperty<bool>(name);
timeSeries->addValue("2012-07-19T16:17:00", true);
......@@ -600,7 +599,8 @@ public:
LogManager runInfo;
const std::string name = "test_has_invalid_values_filter";
const std::string filterName = runInfo.getInvalidValuesFilterLogName(name);
TSM_ASSERT("The filter name should start with the log name",filterName.rfind(name, 0) == 0);
TSM_ASSERT("The filter name should start with the log name",
filterName.rfind(name, 0) == 0);
addTestTimeSeries<double>(runInfo, name);
TS_ASSERT_EQUALS(runInfo.hasInvalidValuesFilter(name), false);
......@@ -619,18 +619,17 @@ public:
filterfail == nullptr);
addTestTimeSeriesFilter(runInfo, filterName);
auto * filter = runInfo.getInvalidValuesFilter(name);
auto *filter = runInfo.getInvalidValuesFilter(name);
TSM_ASSERT("The filter was returned incorrectly as NULL", filter);
TS_ASSERT_THROWS_NOTHING(filter->firstTime());
//check it can be used to filter the log
// check it can be used to filter the log
auto *log = runInfo.getProperty(name);
auto *tsLog = dynamic_cast<TimeSeriesProperty<double>*>(log);
auto *tsLog = dynamic_cast<TimeSeriesProperty<double> *>(log);
TS_ASSERT(tsLog);
if (tsLog) {
auto filtered =
std::make_unique<FilteredTimeSeriesProperty<double>>(tsLog,
*filter);
std::make_unique<FilteredTimeSeriesProperty<double>>(tsLog, *filter);
TS_ASSERT_DELTA(filtered->nthValue(0), 2, 1e-5);
TS_ASSERT_DELTA(filtered->nthValue(1), 3, 1e-5);
TS_ASSERT_DELTA(filtered->nthValue(2), 4, 1e-5);
......
......@@ -6,8 +6,8 @@
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidDataHandling/LoadNexusLogs.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/LogManager.h"
#include "MantidAPI/Run.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/TimeSeriesProperty.h"
#include <locale>
......@@ -284,20 +284,20 @@ std::unique_ptr<Kernel::Property> createTimeSeries(::NeXus::File &file,
}
/**
* Creates a time series validity filter property from the currently opened log entry. It is
* assumed to
* have been checked to have a time field and the value entry's name is given
* as an argument
* Creates a time series validity filter property from the currently opened log
* entry. It is assumed to have been checked to have a time field and the value
* entry's name is given as an argument
* @param file :: A reference to the file handle
* @param prop :: The property to check for a validity array
* @param log :: Reference to logger to print out to
* @returns A pointer to a new property containing the time series filter or null
* @returns A pointer to a new property containing the time series filter or
* null
*/
std::unique_ptr<Kernel::Property>
createTimeSeriesValidityFilter(::NeXus::File &file,
const std::unique_ptr<Kernel::Property> &prop,
Kernel::Logger &log) {
;
createTimeSeriesValidityFilter(::NeXus::File &file,
const std::unique_ptr<Kernel::Property> &prop,
Kernel::Logger &log) {
;
auto tsProp = dynamic_cast<Kernel::ITimeSeriesProperty *>(prop.get());
auto times = tsProp->timesAsVector();
std::vector<int> values;
......@@ -338,7 +338,7 @@ createTimeSeriesValidityFilter(::NeXus::File &file,
bool invalidDataFound = false;
boolValues.reserve(values.size());
//convert the integer values to boolean with 0=valid data
// convert the integer values to boolean with 0=valid data
for (size_t i = 0; i < values.size(); i++) {
bool boolValue = (values[i] != 0);
boolValues.emplace_back(boolValue);
......@@ -348,8 +348,7 @@ createTimeSeriesValidityFilter(::NeXus::File &file,
}
if (invalidDataFound) {
log.warning() << "Some \"" << prop->name() << "\" log data is invalid!\n";
auto tspName =
API::LogManager::getInvalidValuesFilterLogName(prop->name());
auto tspName = API::LogManager::getInvalidValuesFilterLogName(prop->name());
auto tsp = std::make_unique<TimeSeriesProperty<bool>>(tspName);
tsp->create(times, boolValues);
log.debug() << " done reading \"value_valid\" array\n";
......
......@@ -306,22 +306,20 @@ public:
auto run = ws->run();
// This one should not be present as there is no invalid data
TS_ASSERT_THROWS_ANYTHING(run.getLogData(
LogManager::getInvalidValuesFilterLogName("slitpos")));
TS_ASSERT_THROWS_ANYTHING(
run.getLogData(LogManager::getInvalidValuesFilterLogName("slitpos")));
//This one should not be present as there is no invalid data
// This one should not be present as there is no invalid data
TS_ASSERT_THROWS_ANYTHING(run.getLogData(
LogManager::getInvalidValuesFilterLogName("cryo_Sample")));
//these two both contain invalid data
auto pclog1 =
dynamic_cast<TimeSeriesProperty<bool> *>(run.getLogData(
LogManager::getInvalidValuesFilterLogName("cryo_temp1")));
// these two both contain invalid data
auto pclog1 = dynamic_cast<TimeSeriesProperty<bool> *>(run.getLogData(
LogManager::getInvalidValuesFilterLogName("cryo_temp1")));
std::vector<bool> correct{true, false, true};
TS_ASSERT_EQUALS(pclog1->valuesAsVector(), correct);
auto pclog2 =
dynamic_cast<TimeSeriesProperty<bool> *>(run.getLogData(
auto pclog2 = dynamic_cast<TimeSeriesProperty<bool> *>(run.getLogData(
LogManager::getInvalidValuesFilterLogName("cryo_temp2")));
std::vector<bool> correct2{true, true, true};
TS_ASSERT_EQUALS(pclog2->valuesAsVector(), correct2);
......@@ -330,11 +328,11 @@ public:
auto emptyProperty = new TimeSeriesProperty<bool>("empty");
run.filterByLog(*emptyProperty);
auto pclogFiltered1 = dynamic_cast<TimeSeriesProperty<double> *>(run.getLogData("cryo_temp1"));
auto pclogFiltered1 = dynamic_cast<TimeSeriesProperty<double> *>(
run.getLogData("cryo_temp1"));
std::vector<double> correctFiltered1{0., 0., 0.};
TS_ASSERT_EQUALS(pclogFiltered1->valuesAsVector(), correctFiltered1);
auto pclogFiltered2 = dynamic_cast<TimeSeriesProperty<double> *>(
run.getLogData("cryo_temp2"));
std::vector<double> correctFiltered2{0., 0., 0.};
......
// Mantid Repository : https://github.com/mantidproject/mantid
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright &copy; 2007 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
......
......@@ -190,7 +190,7 @@ void PropertyManager::splitByTime(
* @param filter :: A boolean time series to filter each property on
* @param excludedFromFiltering :: A string list of properties that
* will be excluded from filtering
* @param applyInvalidDataFilters :: Wether to also apply any matching invalid
* @param applyInvalidDataFilters :: Wether to also apply any matching invalid
* data filter logs (default:true)
*/
void PropertyManager::filterByProperty(
......@@ -206,8 +206,8 @@ void PropertyManager::filterByProperty(
Property *currentProp = orderedProperty;
if (auto doubleSeries =
dynamic_cast<TimeSeriesProperty<double> *>(currentProp)) {
// don't filter the invalid values filters
if (PropertyManager::isAnInvalidValuesFilterLog(currentProp->name()))
// don't filter the invalid values filters
if (PropertyManager::isAnInvalidValuesFilterLog(currentProp->name()))
break;
std::unique_ptr<Property> filtered(nullptr);
if (this->existsProperty(PropertyManager::getInvalidValuesFilterLogName(
......
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