prubybility 0.0.6 → 0.0.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33eee9f846b8629230180adcfc8a38d77841edec70cb8079b36f52045bd1635e
4
- data.tar.gz: 9bb773d040d89dc0a474df4ff6c4d15db7dcf80fbd040ea12e99d10e55de8322
3
+ metadata.gz: 790170e89a7c891831abb215dbc77ada38b587e6ea631b4f31fcc200d8820ae5
4
+ data.tar.gz: 2dd4031d7521c0cf6b5adf95fca477c2d7c664284496d90868481fccf57fcc56
5
5
  SHA512:
6
- metadata.gz: 964b8d9aa73bc27bd08601d917ed532d13661f0089514489e2c21db541892d248e2f1b11b97fba8bd052c4e46ea918eeae11d71caa1d9eaeee62ee9c8d58223b
7
- data.tar.gz: c4d6c5e783eb589d6317ea81c02cac07274a88f02120b6087cd3fe1c349e6cc4a8f72fe04f592c461324bf51f97e81e8978132c8a5805d335f530938d7d647a3
6
+ metadata.gz: ba3a53b4d9ddd08e3db885f63fde6db6d815ca16c355d6fd669d8eb7424dd137df665554e20d354096c125c940972f981cb43c8ee77677c9b273f0075041c1d5
7
+ data.tar.gz: '091618c288164478bed9703d9929788f9146c1dfce6656598906cbd4e1a06fd23d29cd1fc593e95d28e07ee599b1876d695f6deb93b7c3d748a8407575c3c315'
data/extconf.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  abort "Rust compiler required (https://www.rust-lang.org/)" if `which rustc`.empty?
2
2
 
3
3
  require 'mkmf'
4
- create_makefile '/'
5
- `rake build`
4
+ create_makefile 'prubybility-rust'
5
+ `rake rust_build`
@@ -5,8 +5,6 @@ module Prubybility
5
5
  #
6
6
  # See README for example usages.
7
7
  class Binomial
8
- # include Prubybility::Combinations
9
-
10
8
  attr_reader :n, :theta, :expected_value, :variance
11
9
 
12
10
  alias mean expected_value
@@ -25,7 +23,6 @@ module Prubybility
25
23
  private
26
24
 
27
25
  def choose(var)
28
- return 0.0 if var < 0
29
26
  Prubybility::Combinations.choose(n, var)
30
27
  end
31
28
 
@@ -16,10 +16,22 @@ module Prubybility
16
16
  extern 'char* binom(long, long)'
17
17
 
18
18
  def self.choose(x, y)
19
+ return unless valid_input?(x, y)
20
+
19
21
  ptr = binom(x, y)
20
22
  int = ptr.to_s.to_i
21
23
  free_binom(ptr)
22
24
  int
23
25
  end
26
+
27
+ private
28
+
29
+ def self.valid_input?(x, y)
30
+ return false unless x.is_a?(Integer) && y.is_a?(Integer)
31
+ return false unless x > 0 && y > 0
32
+ return false unless x < 2**64 && y < 2**64
33
+ return false unless x >= y
34
+ true
35
+ end
24
36
  end
25
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prubybility
4
- VERSION = '0.0.6'
4
+ VERSION = '0.0.11'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prubybility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Lee