diff options
author | jasplin <qt-info@nokia.com> | 2010-05-07 14:16:19 +0200 |
---|---|---|
committer | jasplin <qt-info@nokia.com> | 2010-05-07 14:16:19 +0200 |
commit | dc8c7e984827f9092e45471dde8663355ba306db (patch) | |
tree | 76081e65688810cac54ee4acf0cc9f00eadab284 /src/bm | |
parent | 257fd7f5fffeee2cf730b1aea7b921df1be8cc95 (diff) |
Fixed bug in computing stability fractions.
It was effectively (and wrongly!) assumed that at least one
contributing result history would have at least two
subsequences (of contiguous equal values). But this assumption
could easily be violated by setting the median window size
sufficiently high (so that all data was smoothed away!).
Cases like these are now handled and indicated as n/a.
Diffstat (limited to 'src/bm')
-rw-r--r-- | src/bm/bmrequest.cpp | 16 | ||||
-rw-r--r-- | src/bm/dataqualitystats.cpp | 11 |
2 files changed, 18 insertions, 9 deletions
diff --git a/src/bm/bmrequest.cpp b/src/bm/bmrequest.cpp index eee4f68..0025c0a 100644 --- a/src/bm/bmrequest.cpp +++ b/src/bm/bmrequest.cpp @@ -5610,11 +5610,13 @@ void BMRequest_IndexGetValues::handleReply_HTML(const QStringList &args) const "<tr><th></th><th>SF</th></tr>\n"; for (int i = sfPercNodes.size() - 1; i >= 0; --i) { QDomElement sfPercElem = sfPercNodes.at(i).toElement(); + const qreal val = sfPercElem.attributeNode("val").value().toDouble(&ok); reply += QString( - "<tr><td><b>P<sub>%1</sub></b></td><td style=\"text-align:right\">%2%</td></tr>\n") + "<tr><td><b>P<sub>%1</sub></b></td><td style=\"text-align:right%2\">%3</td></tr>\n") .arg(sfPercElem.attributeNode("p").value()) - .arg(QString() - .setNum(sfPercElem.attributeNode("val").value().toDouble(&ok), 'f', 1)); + .arg((val >= 0) ? QString() : QString("; color:red")) + .arg((val >= 0) ? QString("%1%").arg(QString().setNum(val, 'f', 1)) + : QString("n/a")); Q_ASSERT(ok); } reply += "</table></td>\n"; @@ -5624,11 +5626,13 @@ void BMRequest_IndexGetValues::handleReply_HTML(const QStringList &args) const "<tr><th></th><th>SF2</th></tr>\n"; for (int i = sfPercNodes.size() - 1; i >= 0; --i) { QDomElement sfPercElem = sfPercNodes.at(i).toElement(); + const qreal val = sfPercElem.attributeNode("val2").value().toDouble(&ok); reply += QString( - "<tr><td><b>P<sub>%1</sub></b></td><td style=\"text-align:right\">%2%</td></tr>\n") + "<tr><td><b>P<sub>%1</sub></b></td><td style=\"text-align:right%2\">%3</td></tr>\n") .arg(sfPercElem.attributeNode("p").value()) - .arg(QString() - .setNum(sfPercElem.attributeNode("val2").value().toDouble(&ok), 'f', 1)); + .arg((val >= 0) ? QString() : QString("; color:red")) + .arg((val >= 0) ? QString("%1%").arg(QString().setNum(val, 'f', 1)) + : QString("n/a")); Q_ASSERT(ok); } reply += "</table></td>\n"; diff --git a/src/bm/dataqualitystats.cpp b/src/bm/dataqualitystats.cpp index ad6743a..6e46de3 100644 --- a/src/bm/dataqualitystats.cpp +++ b/src/bm/dataqualitystats.cpp @@ -165,10 +165,15 @@ void DataQualityStats::compute(const QList<ResultHistoryInfo *> &rhInfos) // -------- + const int hiPos0 = stabFractions0.size() - 1; + const int hiPos2 = stabFractions2.size() - 1; for (int p = 10; p <= 100; p += 10) { - const int i0 = (stabFractions0.size() - 1) * (p / 100.0); - const int i2 = (stabFractions2.size() - 1) * (p / 100.0); + const int i0 = qMin(hiPos0, static_cast<int>(hiPos0 * (p / 100.0))); + const int i2 = qMin(hiPos2, static_cast<int>(hiPos2 * (p / 100.0))); stabFracPercentiles_.insert( - p, qMakePair(100 * stabFractions0.at(i0), 100 * stabFractions2.at(i2))); + p, qMakePair( + (i0 >= 0) ? (100 * stabFractions0.at(i0)) : -1, + (i2 >= 0) ? (100 * stabFractions2.at(i2)) : -1) + ); } } |