From 6a705494c2321666cbffaf1aff42dbf18d93af63 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sat, 10 Dec 2022 01:27:23 +0100 Subject: [PATCH] invert percentile numbers to expected order --- barcat | 20 ++++++++++---------- t/t1521-count_head.out | 2 +- t/t1522-count_tail.out | 2 +- t/t1524-count_negative_limits.out | 2 +- t/t1608-literal_order.out | 4 ++++ t/t2264-minmax_percent.out | 2 +- 6 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 t/t1608-literal_order.out diff --git a/barcat b/barcat index 1fd0dd3..a129091 100755 --- 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 results, or 68% of all entries, by I<< <--> >>. =item B diff --git a/t/t1521-count_head.out b/t/t1521-count_head.out index 4c8d48d..84b17a1 100644 --- a/t/t1521-count_head.out +++ b/t/t1521-count_head.out @@ -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) diff --git a/t/t1522-count_tail.out b/t/t1522-count_tail.out index 544728c..9c13890 100644 --- a/t/t1522-count_tail.out +++ b/t/t1522-count_tail.out @@ -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) diff --git a/t/t1524-count_negative_limits.out b/t/t1524-count_negative_limits.out index f3bc8ce..6176937 100644 --- a/t/t1524-count_negative_limits.out +++ b/t/t1524-count_negative_limits.out @@ -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 index 0000000..dddc755 --- /dev/null +++ b/t/t1608-literal_order.out @@ -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) diff --git a/t/t2264-minmax_percent.out b/t/t2264-minmax_percent.out index 7126c7a..e15041d 100644 --- a/t/t2264-minmax_percent.out +++ b/t/t2264-minmax_percent.out @@ -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 (-------------- -- 2.30.0