cotcube-helpers 0.1.7 → 0.1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/VERSION +1 -1
- data/lib/cotcube-helpers.rb +2 -0
- data/lib/cotcube-helpers/simple_series_stats.rb +7 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c53dd160cd7774a8808b28681dd7ad363cb46f7b69ae402d89c190e531060837
|
4
|
+
data.tar.gz: 0f0731c06b715e753c73685f7acc967881b616410edde425705f43c38df601fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3920e5754a1b8ae41f8d0ebe83502d9935766b08da022367694fe0ed4591e7c759378a8badca27e0672851fb7599ad97ceff1986146add4285ce4386d8e5852a
|
7
|
+
data.tar.gz: 419275382240a93ad604cb32208b57e1b9e3cbf9db95bd0853b80b0fe4a29c10d162af2a20d801c5cb19fd04296d6519b442d66786e5bc56d82ee4f0da37b841
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.7
|
1
|
+
0.1.7.1
|
data/lib/cotcube-helpers.rb
CHANGED
@@ -16,6 +16,7 @@ require_relative 'cotcube-helpers/datetime_ext'
|
|
16
16
|
require_relative 'cotcube-helpers/subpattern'
|
17
17
|
require_relative 'cotcube-helpers/parallelize'
|
18
18
|
require_relative 'cotcube-helpers/simple_output'
|
19
|
+
require_relative 'cotcube-helpers/simple_series_stats'
|
19
20
|
require_relative 'cotcube-helpers/input'
|
20
21
|
require_relative 'cotcube-helpers/reduce'
|
21
22
|
|
@@ -24,6 +25,7 @@ module Cotcube
|
|
24
25
|
module_function :sub,
|
25
26
|
:parallelize,
|
26
27
|
:reduce,
|
28
|
+
:simple_series_stats,
|
27
29
|
:keystroke
|
28
30
|
|
29
31
|
# please not that module_functions of source provided in private files must be published there
|
@@ -5,7 +5,7 @@ module Cotcube
|
|
5
5
|
module Helpers
|
6
6
|
# if given a block, :ind of base is set by block.call()
|
7
7
|
# dim reduces the sample size by top n% and least n%, so dim of 0.5 would remove 100% of the sample
|
8
|
-
def simple_series_stats(base:, ind: nil, dim: 0, format: '%
|
8
|
+
def simple_series_stats(base:, ind: nil, dim: 0, format: '% 6.2f', prefix: '', print: true, &block)
|
9
9
|
raise ArgumentError, 'Need :ind of type integer' if base.first.is_a?(Array) and not ind.is_a?(Integer)
|
10
10
|
raise ArgumentError, 'Need :ind to evaluate base' if base.first.is_a?(Hash) and ind.nil?
|
11
11
|
|
@@ -37,15 +37,16 @@ module Cotcube
|
|
37
37
|
result[:upper] = worker[ (result[:size] * 3 / 4).round ]
|
38
38
|
result[:max] = worker.last
|
39
39
|
|
40
|
-
|
40
|
+
output = result.
|
41
41
|
reject{|k,_| k == :size}.
|
42
42
|
map{|k,v| { type: k, value: v, output: "#{k}: #{format(format, v)}".colorize(k==:avg ? :light_yellow : :white) } }.
|
43
43
|
sort_by{|x| x[:value]}.
|
44
44
|
map{|x| x[:output]}
|
45
|
-
output = "
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
result[:output] = "#{format '%20s',(prefix.empty? ? '' : (prefix + ': '))}" +
|
46
|
+
"[" +
|
47
|
+
" size: #{format '%6d', result[:size]} | ".light_white +
|
48
|
+
output.join(' | ') +
|
49
|
+
" ]"
|
49
50
|
|
50
51
|
puts result[:output] if print
|
51
52
|
result
|