diff --git a/yoshimi-testrunner/src/util/data.hpp b/yoshimi-testrunner/src/util/data.hpp index f3e0b3e12..8dd3d7589 100644 --- a/yoshimi-testrunner/src/util/data.hpp +++ b/yoshimi-testrunner/src/util/data.hpp @@ -253,6 +253,17 @@ public: }); } + void dropLastRow() + { + if (not empty()) + forEach(TAB::allColumns(), + [](auto& col) + { + size_t siz = col.data.size(); + col.data.resize(siz>0? siz-1 : 0); + }); + } + void reserve(size_t expectedCapacity) { forEach(TAB::allColumns(), @@ -282,6 +293,7 @@ public: fs::rename(filename_, oldFile); } fs::rename(newFilename, filename_); + filename_ = consolidated(filename_); // lock onto absolute path } diff --git a/yoshimi-testrunner/src/util/regex.hpp b/yoshimi-testrunner/src/util/regex.hpp index 1aae85bc0..169a75b55 100644 --- a/yoshimi-testrunner/src/util/regex.hpp +++ b/yoshimi-testrunner/src/util/regex.hpp @@ -32,9 +32,12 @@ #include #include +#include namespace util { +using std::regex; +using std::smatch; using std::string; @@ -43,7 +46,7 @@ using std::string; struct MatchSeq : std::sregex_iterator { - MatchSeq(string const& toParse, std::regex const& regex) + MatchSeq(string const& toParse, regex const& regex) : std::sregex_iterator{toParse.begin(), toParse.end(), regex} { } @@ -53,5 +56,32 @@ struct MatchSeq }; + +/** encapsulated regex buildable from string */ +class Matcher +{ + std::optional pattern_; + +public: + Matcher() = default; + Matcher(string const& regexDefinition) + : pattern_{regexDefinition.empty()? std::nullopt + : std::make_optional(regexDefinition, regex::optimize)} + { } + // standard copy acceptable + + explicit operator bool() const + { + return bool(pattern_); + } + + bool matchesWithin(string probe) const + { + return pattern_? std::regex_search(probe, *pattern_) + : true; // undefined pattern matches everything + } +}; + + }//(End)namespace util #endif /*TESTRUNNER_UTIL_REGEX_HPP_*/ diff --git a/yoshimi-testrunner/src/util/statistic.hpp b/yoshimi-testrunner/src/util/statistic.hpp index 80c1a12d7..c2ab6bb96 100644 --- a/yoshimi-testrunner/src/util/statistic.hpp +++ b/yoshimi-testrunner/src/util/statistic.hpp @@ -243,7 +243,7 @@ inline auto computeLinearRegression(DataSpan const& points) double socket = ym - gradient * xm; // Regression line: Y-ym = gradient · (x-xm) ; set x≔0 yields socket // Correlation (Pearson's r) - double correlation = wyysum==0.0? 0.0 : gradient * sqrt(varx/vary); + double correlation = wyysum==0.0? 1.0 : gradient * sqrt(varx/vary); // calculate error Δ for all measurement points size_t n = points.size(); @@ -304,7 +304,7 @@ inline auto computeTimeSeriesLinearRegression(DataSpan const& series) double socket = ym - gradient * im; // Regression line: Y-ym = Gradient · (i-im) ; set i≔0 yields socket // Correlation (Pearson's r) - double correlation = yysum==0.0? 0.0 : gradient * sqrt(varx/vary); + double correlation = yysum==0.0? 1.0 : gradient * sqrt(varx/vary); return make_tuple(socket,gradient,correlation); }