Summary: | Curves with only NaNs break autoscaling | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Nicolas Brisset <nicolas.brisset> |
Component: | general | Assignee: | kst |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 1.x | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Solaris | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | Proposed patch |
Description
Nicolas Brisset
2006-06-20 14:18:51 UTC
*** Bug 129485 has been marked as a duplicate of this bug. *** Created attachment 16720 [details]
Proposed patch
The underlying problem is caused by the incorrect calculation of the various
statistics associated with a curve containing only NaN values.
SVN commit 553302 by arwalker: BUG:129484 Correctly calculate statistical values for curves holding only NaN values. M +13 -7 kstvector.cpp --- trunk/extragear/graphics/kst/src/libkst/kstvector.cpp #553301:553302 @@ -305,7 +305,7 @@ } else { _scalars["sigma"]->setValue(_max - _min); _scalars["rms"]->setValue(sqrt(_scalars["sumsquared"]->value())); - _scalars["mean"]->setValue(_mean = 0); + _scalars["mean"]->setValue(_mean = KST::NOPOINT); } } } @@ -415,14 +415,18 @@ double sum, sum2, last, v; double last_v; double dv2 = 0.0, dv, no_spike_max_dv; - _max = _min = sum = sum2 = _minPos = last = 0.0; + + _max = _min = sum = sum2 = _minPos = last = KST::NOPOINT; _nsum = 0; + if (_size > 0) { _is_rising = true; // FIXME: expensive!! Can we somehow cache this at least? - for (i = 0; i < _size && !finite(_v[i]); i++) - /* Do Nothing */ ; + for (i = 0; i < _size && !finite(_v[i]); i++) { + // do nothing + } + if (i == _size) { if (!_isScalarList) { _scalars["sum"]->setValue(sum); @@ -435,6 +439,7 @@ _ns_max = _ns_min = 0; updateScalars(); + return setLastUpdateResult(providerRC); } @@ -447,13 +452,14 @@ _max = _min = _v[i0]; sum = sum2 = 0.0; - if (_v[i0] > 0) { + if (_v[i0] > 0.0) { _minPos = _v[i0]; } else { _minPos = 1.0E300; } last_v = _v[i0]; + for (i = i0; i < _size; i++) { v = _v[i]; // get rid of redirections @@ -478,8 +484,8 @@ } else if (v < _min) { _min = v; } - if (v < _minPos && v > 0) { - _minPos = v; + if (v < _minPos && v > 0.0) { + _minPos = v; } } else { _is_rising = false; |