diff base/test/TestScaleTickIntervals.h @ 1460:9528c73aa98c horizontal-scale

Simpler & more consistent log scale tick calculation
author Chris Cannam
date Wed, 02 May 2018 15:42:36 +0100
parents 3a128665fa6f
children 2b2b58ae8b59
line wrap: on
line diff
--- a/base/test/TestScaleTickIntervals.h	Wed May 02 14:17:10 2018 +0100
+++ b/base/test/TestScaleTickIntervals.h	Wed May 02 15:42:36 2018 +0100
@@ -428,7 +428,7 @@
         // pathological range
         auto ticks = ScaleTickIntervals::linear({ 1, 1, 10 });
         ScaleTickIntervals::Ticks expected {
-            { 1.0, "1.0" }
+            { 1.0, "1" }
         };
         compareTicks(ticks, expected);
     }
@@ -498,8 +498,8 @@
         auto ticks = ScaleTickIntervals::logarithmic({ 1, 10, 2 });
         ScaleTickIntervals::Ticks expected {
             { 1.0, "1.0" },
-            { pow(10.0, 0.5), "3.2" },
-            { 10.0, "10.0" },
+            { 3.2, "3.2" },
+            { 10.0, "10" },
         };
         compareTicks(ticks, expected);
     }
@@ -518,7 +518,7 @@
     {
         auto ticks = ScaleTickIntervals::logarithmic({ M_PI, 6.022140857e23, 7 });
         ScaleTickIntervals::Ticks expected {
-            { 1000, "1000.0" },
+            { 1000, "1000" },
             { 1e+06, "1e+06" },
             { 1e+09, "1e+09" },
             { 1e+12, "1e+12" },
@@ -533,17 +533,17 @@
     {
         auto ticks = ScaleTickIntervals::logarithmic({ 0.465, 778.08, 10 });
         ScaleTickIntervals::Ticks expected {
-            { 0.5, "0.5" },
+            { 0.5, "0.50" },
             { 1, "1.0" },
             { 2, "2.0" },
             { 4, "4.0" },
             { 8, "8.0" },
-            { 16, "16.0" },
-            { 32, "32.0" },
-            { 64, "64.0" },
-            { 128, "128.0" },
-            { 256, "256.0" },
-            { 512, "512.0" },
+            { 16, "16" },
+            { 32, "32" },
+            { 64, "64" },
+            { 130, "130" },
+            { 260, "260" },
+            { 510, "510" },
         };
         compareTicks(ticks, expected);
     }
@@ -554,14 +554,14 @@
         ScaleTickIntervals::Ticks expected {
             { 1.0, "1.0" },
             { 2.5, "2.5" },
-            { 6.0, "6.0" },
-            { 16.0, "16.0" },
-            { 40.0, "40.0" },
-            { 100.0, "100.0" },
-            { 250.0, "250.0" },
-            { 600.0, "600.0" },
-            { 1600.0, "1600.0" },
-            { 4000.0, "4000.0" },
+            { 6.3, "6.3" },
+            { 16.0, "16" },
+            { 40.0, "40" },
+            { 100.0, "100" },
+            { 250.0, "250" },
+            { 630.0, "630" },
+            { 1600.0, "1600" },
+            { 4000.0, "4000" },
             { 10000.0, "1e+04" },
         };
         compareTicks(ticks, expected, true);
@@ -587,13 +587,13 @@
         auto ticks = ScaleTickIntervals::logarithmic({ 80.0, 800000.0, 10 });
         ScaleTickIntervals::Ticks expected {
             { 100, "100" },
-            { 251, "251" },
-            { 631, "631" },
-            { 1580, "1580" },
-            { 3980, "3980" },
-            { 10000, "10000" },
-            { 25100, "2.5e+04" },
-            { 63100, "6.3e+04" },
+            { 250, "250" },
+            { 630, "630" },
+            { 1600, "1600" },
+            { 4000, "4000" },
+            { 10000, "1e+04" },
+            { 25000, "2.5e+04" },
+            { 63000, "6.3e+04" },
             { 160000, "1.6e+05" },
             { 400000, "4e+05" },
         };