Bug 129484

Summary: Curves with only NaNs break autoscaling
Product: [Applications] kst Reporter: Nicolas Brisset <nicolas.brisset>
Component: generalAssignee: 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
Version:           1.3.0_devel (using KDE 3.4.0, compiled sources)
Compiler:          gcc version 3.4.3
OS:                SunOS (sun4u) release 5.8

It seems that curves with only NaNs break autoscale. To reproduce:

- load column 2 from gyrodata.dat
- use the "shift" filter and shift it by more than its length (e.g. 300000 points)
- it looks like NaNs are considered as 0 by the autoscaling algorithm

It would be better to automatically ignore curves with only NaNs in the autoscale computation (as can be done manually now with the checkbox in the curve dialog)
Comment 1 Nicolas Brisset 2006-06-20 15:06:32 UTC
*** Bug 129485 has been marked as a duplicate of this bug. ***
Comment 2 Andrew Walker 2006-06-20 18:57:24 UTC
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.
Comment 3 Andrew Walker 2006-06-20 19:11:43 UTC
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;