rstat 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e6b78f26684385b1bcc496f11492bee33abdec55
4
+ data.tar.gz: bc1e3f0d1b20e378fbe32d18e69238687f0b0dfa
5
+ SHA512:
6
+ metadata.gz: f0e6ddff2517cf0ce64579e9b9488375485f09dad5e63c9514f9d055b736f97c9f5e10c122fe96890ffce969d2aec81e51059c451f4080da9645d21b16df5fba
7
+ data.tar.gz: b08e58e0305ccc76953384bf8abd51de2fa97ae36b1d449d5cce1e59829792de92bddd19d3e8b67d72c6f47518ebbd0c9a0d8ba245e87a389c1766ade0163d29
@@ -0,0 +1 @@
1
+ rstat
@@ -0,0 +1 @@
1
+ 2.0.0-p247
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.8.7"
4
+ - "1.9.2"
5
+ - "1.9.3"
6
+ - "2.0.0"
7
+ - jruby-18mode
8
+ - jruby-19mode
9
+ - rbx-18mode
10
+ - rbx-19mode
11
+ script: bundle exec rspec spec
@@ -1,3 +1,7 @@
1
+ ## v0.1.2
2
+ * Use inject(:*) rather than inject(1, &:*) for binomial_coefficient.
3
+ * Fixed some tests to work with 1.8.7."
4
+
1
5
  ## v0.1.1
2
6
 
3
7
  * Made rstat.rb load all files automatically instead of listing them manually.
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in rstat.gemspec
4
3
  gemspec
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Rstat
2
2
 
3
+ [![Gem Version](https://fury-badge.herokuapp.com/rb/rstat.png)](http://badge.fury.io/rb/rstat)
4
+ [![Travis](https://api.travis-ci.org/seaneshbaugh/rstat.png)](http://travis-ci.org/seaneshbaugh/rstat)
5
+
3
6
  A very simple statistics gem.
4
7
 
5
8
  ## Installation
@@ -76,7 +79,7 @@ To run one particular line of a spec file:
76
79
 
77
80
  $ rspec spec/rstat/array_spec.rb:177
78
81
 
79
- Rstat has been tested with Ruby 1.8.7 and 1.9.3. There's little reason it shouldn't work with other versions of Ruby though.
82
+ Rstat has been tested with Ruby 1.8.7, 1.9.3, and 2.0.0. There's little reason it shouldn't work with other versions of Ruby though.
80
83
 
81
84
  ## Console
82
85
 
@@ -88,7 +91,6 @@ Rstat includes a rake task to open up an irb session with the gem source preload
88
91
 
89
92
  If you feel like you can add something useful to Rstat then don't hesitate to send a pull request.
90
93
 
91
-
92
94
  ## A Note of Warning
93
95
 
94
96
  This gem extends the core Array class and Fixnum class. In isolation this is usually pretty harmless. But, in combination with other gems that do the same, unpredictable behavior may result. As always, use caution, and be aware of what this gem and any others you use actually do before including it in an important project.
@@ -10,6 +10,6 @@ class Array
10
10
 
11
11
  max = seen.values.max
12
12
 
13
- seen.find_all{ |key, value| value == max }.map{ |key, value| key }
13
+ seen.find_all{ |key, value| value == max }.map{ |key, value| key }.sort
14
14
  end
15
15
  end
@@ -1,5 +1,5 @@
1
1
  class Fixnum
2
2
  def binomial_coefficient(bottom)
3
- (self - bottom + 1 .. self).inject(1, &:*) / (2 .. bottom).inject(1, &:*)
3
+ (self - bottom + 1 .. self).inject(:*) / (2 .. bottom).inject(:*)
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module Rstat
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -30,8 +30,14 @@ describe Rstat do
30
30
  [0, 2, 3, 4, 5].geometric_mean.should eql(0.0)
31
31
  end
32
32
 
33
- it 'calculates the geometric mean of an array with a negative element' do
34
- [-1, 2, 3, 4, 5].geometric_mean.real?.should be_false
33
+ if Fixnum.method_defined?(:real?)
34
+ it 'calculates the geometric mean of an array with a negative element' do
35
+ [-1, 2, 3, 4, 5].geometric_mean.real?.should be_false
36
+ end
37
+ else
38
+ it 'should return NaN when calculating the geometric mean of an array with a negative element' do
39
+ [-1, 2, 3, 4, 5].geometric_mean.nan?.should be_true
40
+ end
35
41
  end
36
42
  end
37
43
 
@@ -26,12 +26,16 @@ describe Rstat do
26
26
 
27
27
  describe '.simple_linear_regression_slope' do
28
28
  it 'should return the slope of the linear regression equation for two arrays' do
29
+ Rstat.simple_linear_regression_slope([1, 2, 3, 4, 5], [1, 2, 3, 4, 5]).should be_within(0.00001).of(1.0)
30
+
29
31
  Rstat.simple_linear_regression_slope([60, 61, 62, 63, 65], [3.1, 3.6, 3.8, 4, 4.1]).should be_within(0.00001).of(0.18784)
30
32
  end
31
33
  end
32
34
 
33
35
  describe '.simple_linear_regression_intercept' do
34
36
  it 'should return the slope of the linear regression equation for two arrays' do
37
+ Rstat.simple_linear_regression_intercept([1, 2, 3, 4, 5], [1, 2, 3, 4, 5]).should be_within(0.00001).of(0.0)
38
+
35
39
  Rstat.simple_linear_regression_intercept([60, 61, 62, 63, 65], [3.1, 3.6, 3.8, 4, 4.1]).should be_within(0.00001).of(-7.96351)
36
40
  end
37
41
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rstat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sean Eshbaugh
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-04 00:00:00.000000000 Z
11
+ date: 2013-08-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  description: A Simple statistics gem.
@@ -36,7 +33,9 @@ extra_rdoc_files: []
36
33
  files:
37
34
  - .gitignore
38
35
  - .rspec
39
- - .rvmrc
36
+ - .ruby-gemset
37
+ - .ruby-version
38
+ - .travis.yml
40
39
  - CHANGELOG.md
41
40
  - Gemfile
42
41
  - README.md
@@ -75,27 +74,26 @@ files:
75
74
  - spec/spec_helper.rb
76
75
  homepage: https://github.com/seaneshbaugh/rstat
77
76
  licenses: []
77
+ metadata: {}
78
78
  post_install_message:
79
79
  rdoc_options: []
80
80
  require_paths:
81
81
  - lib
82
82
  required_ruby_version: !ruby/object:Gem::Requirement
83
- none: false
84
83
  requirements:
85
- - - ! '>='
84
+ - - '>='
86
85
  - !ruby/object:Gem::Version
87
86
  version: '0'
88
87
  required_rubygems_version: !ruby/object:Gem::Requirement
89
- none: false
90
88
  requirements:
91
- - - ! '>='
89
+ - - '>='
92
90
  - !ruby/object:Gem::Version
93
91
  version: '0'
94
92
  requirements: []
95
93
  rubyforge_project: rstat
96
- rubygems_version: 1.8.23
94
+ rubygems_version: 2.0.3
97
95
  signing_key:
98
- specification_version: 3
96
+ specification_version: 4
99
97
  summary: A Simple statistics gem.
100
98
  test_files:
101
99
  - spec/rstat/array_spec.rb
data/.rvmrc DELETED
@@ -1,80 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
- # development environment upon cd'ing into the directory
5
-
6
- # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
- environment_id="ruby-1.9.3-p194@rstat"
8
-
9
- #
10
- # Uncomment the following lines if you want to verify rvm version per project
11
- #
12
- # rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start
13
- # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
- # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
- # return 1
16
- # }
17
- #
18
-
19
- #
20
- # Uncomment following line if you want options to be set only for given project.
21
- #
22
- # PROJECT_JRUBY_OPTS=( --1.9 )
23
- #
24
- # The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
25
- #
26
- # chmod +x ${rvm_path}/hooks/after_use_jruby_opts
27
- #
28
-
29
- #
30
- # First we attempt to load the desired environment directly from the environment
31
- # file. This is very fast and efficient compared to running through the entire
32
- # CLI and selector. If you want feedback on which environment was used then
33
- # insert the word 'use' after --create as this triggers verbose mode.
34
- #
35
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
36
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
37
- then
38
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
39
-
40
- if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
41
- then
42
- . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
43
- fi
44
- else
45
- # If the environment file has not yet been created, use the RVM CLI to select.
46
- if ! rvm --create "$environment_id"
47
- then
48
- echo "Failed to create RVM environment '${environment_id}'."
49
- return 1
50
- fi
51
- fi
52
-
53
- #
54
- # If you use an RVM gemset file to install a list of gems (*.gems), you can have
55
- # it be automatically loaded. Uncomment the following and adjust the filename if
56
- # necessary.
57
- #
58
- # filename=".gems"
59
- # if [[ -s "$filename" ]]
60
- # then
61
- # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
62
- # fi
63
-
64
- # If you use bundler, this might be useful to you:
65
- # if [[ -s Gemfile ]] && ! command -v bundle >/dev/null
66
- # then
67
- # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
68
- # gem install bundler
69
- # fi
70
- # if [[ -s Gemfile ]] && command -v bundle
71
- # then
72
- # bundle install
73
- # fi
74
-
75
- if [[ $- == *i* ]] # check for interactive shells
76
- then
77
- echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
78
- else
79
- echo "Using: $GEM_HOME" # don't use colors in interactive shells
80
- fi