kujibiki 0.2.0 → 0.2.1

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: 5a00aa2d312cdb6a276739da7fd703594f1d6d77
4
- data.tar.gz: ec1f679ddd807cb3d49af9e03dd1d9d80a7c2a16
3
+ metadata.gz: eccc6d249e913c599a87624d0300d6ea0b7f1a02
4
+ data.tar.gz: d2e1a47e35a35ec9ae9e1879902095515e34e63a
5
5
  SHA512:
6
- metadata.gz: d33baa2cce6c158200ca79930aaf358c879fe0ef68390f565ebb945479dd95c174031db0f81a5274bf8df37979f4867bf1bab2b5fa3abf3b918dca96164ebc43
7
- data.tar.gz: 9981869ef4d582dc539828bd8be38c8ef285ef3221d7772b584dcd12370b94ce6d338562e084a553c2c85f2cb0c4220e24388fd24bc60a54ffc389b129282990
6
+ metadata.gz: b3e70ca7f2a0fff49e0dc17cc41585d92cdd26ef2883c35cbe80a3da448c92b0897a6940752670b5a1a3bd3d30c8baba065ed18dbe8b357b25e888ad5af9f054
7
+ data.tar.gz: db6ca4c61023f89d05d4201010223afc42609e0eba9733ecbb593ce93483f1b10def4b5c1d29169f206c3f98434d96645194e704256183c05cde332c268ff3b8
@@ -4,9 +4,11 @@ class Array
4
4
  return call_original_sample(n, random: random) if (weight.nil? || self.size <= 1)
5
5
 
6
6
  unless weight.select {|w| w > 0}.size >= self.size
7
- raise ArgumentError, "weight size must be larger than or equal to sample number(#{self.size})"
7
+ raise ArgumentError, "weight size must be equal to array size(#{self.size})"
8
8
  end
9
9
 
10
+ n = self.size if n > self.size
11
+
10
12
  begin
11
13
  sum = weight.inject(0.0, :+)
12
14
  normalized_hash = self.each_with_object({}).with_index do |(e, h), i|
@@ -1,3 +1,3 @@
1
1
  module Kujibiki
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kujibiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naoki Shimizu