invert percentile numbers to expected order
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 10 Dec 2022 00:27:23 +0000 (01:27 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 12 Dec 2022 22:56:34 +0000 (23:56 +0100)
barcat
t/t1521-count_head.out
t/t1522-count_tail.out
t/t1524-count_negative_limits.out
t/t1608-literal_order.out [new file with mode: 0644]
t/t2264-minmax_percent.out

diff --git a/barcat b/barcat
index 1fd0dd3e8815c8879569fc3bf0e4fa5c679524d5..a129091c4418f59b511f801236e6094e351bddd5 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -145,7 +145,7 @@ $opt{units}   = [split //, ' kMGTPEZYRQqryzafpn'.($opt{ascii} ? 'u' : 'μ').'m']
 $opt{'value-length'} = 4 if $opt{units};
 $opt{'value-length'} = 1 if $opt{unmodified};
 $opt{'signal-stat'} //= exists $SIG{INFO} ? 'INFO' : 'QUIT';
-$opt{markers} //= '=avg >31.73v <68.27v +50v |0';
+$opt{markers} //= '=avg <31.73v >68.27v +50v |0';
 $opt{report} //= join('',
        '${partsum+; $_ .= " of "}',
        '${sum+; color(1); $_ .= " total in "}',
@@ -204,7 +204,7 @@ if (defined $opt{interval}) {
 
        eval {
                require Tie::Array::Sorted;
-               tie @order, 'Tie::Array::Sorted', sub { $_[1] <=> $_[0] };
+               tie @order, 'Tie::Array::Sorted', sub { $_[0] <=> $_[1] };
        } or warn $@, "Expect slowdown with large datasets!\n"
                unless $opt{count};
 }
@@ -268,12 +268,12 @@ if ($opt{count}) {
        @order = @values;
 }
 
-@order = sort { $b <=> $a } @order unless tied @order;
+@order = sort { $a <=> $b } @order unless tied @order;
 my $maxval = $opt{maxval} // (
        $opt{hidemax} ? max grep { length } @values[$nr .. $limit] :
-       $order[0]
+       $order[-1]
 ) // 0;
-my $minval = $opt{minval} // min $order[-1] // (), 0;
+my $minval = $opt{minval} // min $order[0] // (), 0;
 my $range = $maxval - $minval;
 $range &&= log $range if $opt{log};
 my $lenval = $opt{'value-length'} // max map { length } @order;
@@ -342,13 +342,13 @@ while ($nr <= $limit) {
                $rel = min(1, $rel / $range) if $range; # 0..1
        }
        my $color = !length $val || !$opt{palette} ? undef :
-               $val == $order[0] ? $opt{palette}->[-1] : # max
-               $val == $order[-1] ? $opt{palette}->[0] : # min
+               $val == $order[-1] ? $opt{palette}->[-1] : # max
+               $val == $order[0] ? $opt{palette}->[0] : # min
                $opt{palette}->[ $rel * ($#{$opt{palette}} - 1) + 1 ];
        my $indicator = $opt{indicators} && $opt{indicators}->[
                !length($val) || !$#{$opt{indicators}} ? 0 : # blank
                $#{$opt{indicators}} < 2 ? 1 :
-               $val >= $order[0] ? -1 :
+               $val >= $order[-1] ? -1 :
                $rel * ($#{$opt{indicators}} - 1e-14) + 1
        ];
 
@@ -654,8 +654,8 @@ in its frequency distribution (inclusive).
 
 The default shows C<+> at C<50v> for the mean or median:
 the middle value or interpolation between two values.
-One standard deviation below the median is at about C<68v>.
-The default includes C<< >31.73v <68.27v >>
+One standard deviation above the median is at about C<68v>.
+The default includes C<< <31.73v >68.27v >>
 to encompass all I<normal> results, or 68% of all entries, by I<< <--> >>.
 
 =item B<avg>
index 4c8d48dbba8ee88955f9e0c50cf12e3a60d1fbdb..84b17a12ebdcc977697473ac6f5893b04a5aad44 100644 (file)
@@ -1,3 +1,3 @@
 barcat -L1 -s input/aligned.txt
   1 ------------------------------------
-1 of 35 total in 7 values (1 min, 5.00 avg, 010 max)
+1 of 35 total in 7 values (1 min, 5.00 avg, 10 max)
index 544728c562eb9fcf331396fb8b622511d15bcc31..9c138905fdf440750ee7ade61388023e3eced61d 100644 (file)
@@ -1,3 +1,3 @@
 barcat -L-1 -s input/aligned.txt
 5.0less --------<---+--=
-5 of 35 total in 7 values (1 min, 5.00 avg, 010 max)
+5 of 35 total in 7 values (1 min, 5.00 avg, 10 max)
index f3bc8ce33234d27509b80d08ae675aee94d0eb75..6176937573b958ff919e6e4fd0ce2eb6426a6345 100644 (file)
@@ -1,3 +1,3 @@
 barcat -L-2+1 -s input/aligned.txt
  10. more --------<--+--=>--------------
-10 of 35 total in 7 values (1 min, 5.00 avg, 010 max)
+10 of 35 total in 7 values (1 min, 5.00 avg, 10 max)
diff --git a/t/t1608-literal_order.out b/t/t1608-literal_order.out
new file mode 100644 (file)
index 0000000..dddc755
--- /dev/null
@@ -0,0 +1,4 @@
+barcat -s -L-3-2 002 02 0002 001 01 0001 003 03 0003
+ 003 -----------------<----+----->------
+  03 -----------------<----+----->------
+6 of 18 total in 9 values (001 min, 2.00 avg, 0003 max)
index 7126c7a06514f91178631851f4db7ed9d56513e5..e15041d9c81a130d6c28936343664244b60b7d11 100644 (file)
@@ -1,4 +1,4 @@
-barcat --markers=')0v (100v' input/ascii.txt
+barcat --markers='(0v )100v' input/ascii.txt
 123e-6 micro     (---------------------
     .1 long line (---------------------)
     -1           (--------------