pikk 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a54b718fdcbaeaab7308714745c25eac5307470
4
- data.tar.gz: f2ac55e78df3d66096665e20d640a7ef3835f1a9
3
+ metadata.gz: d97b702d042636b17c668e22f5a6bef93009a512
4
+ data.tar.gz: e4a863a8a21260328dbf50dccba7a8012bf1e0ec
5
5
  SHA512:
6
- metadata.gz: 6173337493b12f7739043475480138ed2e8764fc7866d4e8aaedb87985c0e9303106ce904db7968e9a57533d2484efb083534f7600cfec3c2e9a7afb9bcbd1c9
7
- data.tar.gz: f6b796f2fe5e5225d0fda61e24fa51a15d089de0e76d6a724c52804f4266645e24fbb15a1c0d41be0a5327596dedff90d5f7ce824d1019d7ea313c51b139d199
6
+ metadata.gz: 1b6c4aad7f320cb141d456197252f77c64bd5c91e4801ee4a01b1f8fbe3c6b27c9ab0d08671d9c24fee11ea736aec4ec4f7b577b041a353618330effec9054bf
7
+ data.tar.gz: cd701a86d763b4ce87f488ea2fa5fb0196eec9e1905a051cf277c4b9f56e9d3e54b191e385f3c43e5a90dc932635aac24106750a5213feb327af687e46026eac
data/README.md CHANGED
@@ -23,7 +23,7 @@ Or install it yourself as:
23
23
  > **WARNING!**
24
24
  > **Your hash should have the keys `:name` and `:weight`!**
25
25
 
26
- There are two methods. One is `single_select` and the other is `pool`. Former, select one hash object from the array by its weight, and return it. Latter, do an iteration of selection, 50 by default, and return the array.
26
+ There are two methods. One is `single_select` and the other is `pool`. Former, select one hash object from the array by its weight, and return it. Latter, do an iteration of selection, 50 by default, and return the array. See [examples/](https://github.com/aoozdemir/pikk/blob/master/examples/object_example.rb) for more.
27
27
 
28
28
  ```ruby
29
29
  require 'pikk'
@@ -44,19 +44,17 @@ Pikk.pool(ary, pp: true)
44
44
  # +-----------------+--------+-------+---------------------+--------------------+
45
45
  # | Name | Weight | Count | Probability | (C/(P*I)) |
46
46
  # +-----------------+--------+-------+---------------------+--------------------+
47
- # | a | 5.5 | 19 | 0.3235294117647059 | 1.1745454545454546 |
48
- # | b | 3 | 8 | 0.17647058823529413 | 0.9066666666666666 |
49
- # | c | 7 | 19 | 0.4117647058823529 | 0.9228571428571429 |
50
- # | d | 1.5 | 4 | 0.08823529411764706 | 0.9066666666666666 |
47
+ # | c | 7 | 417 | 0.4117647058823529 | 1.0127142857142857 |
48
+ # | a | 5.5 | 309 | 0.3235294117647059 | 0.955090909090909 |
49
+ # | b | 3 | 163 | 0.17647058823529413 | 0.9236666666666666 |
50
+ # | d | 1.5 | 111 | 0.08823529411764706 | 1.258 |
51
51
  # +-----------------+--------+-------+---------------------+--------------------+
52
- # | Iteration Count | 50 |
52
+ # | Iteration Count | 1000 |
53
53
  # +-----------------+--------+-------+---------------------+--------------------+
54
- # | Sum Ratio | 0.02231601731601729 |
54
+ # | Sum Ratio | 0.03736796536796527 |
55
55
  # +-----------------+--------+-------+---------------------+--------------------+
56
56
  ```
57
57
 
58
-
59
-
60
58
  ## Development
61
59
 
62
60
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/pikk/main.rb CHANGED
@@ -51,7 +51,7 @@ module Pikk
51
51
  end
52
52
 
53
53
  def to_table(list = [{}])
54
- list.sort_by { |h| h[:weight] }.reverse!
54
+ list.sort_by! { |h| h[:weight] }.reverse!
55
55
 
56
56
  lsum = 0
57
57
 
@@ -67,7 +67,6 @@ module Pikk
67
67
  add_row ['Iteration Count', { value: $iteration, colspan: 4, alignment: :right }]
68
68
  add_separator
69
69
  add_row ['Sum Ratio', { value: (1 - lsum / list.count).abs, colspan: 4, alignment: :right }]
70
- align_column 1, :center
71
70
  end
72
71
 
73
72
  puts ltable
data/lib/pikk/version.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Pikk
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- TINY = 1
6
+ TINY = 2
7
7
 
8
8
  VERSION = [MAJOR, MINOR, TINY].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pikk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oguzhan Ozdemir