Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: ruby
rvm:
- 2.6.3
- 2.3.0
- 2.2.0
- 2.1.0
Expand Down
46 changes: 25 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.2.5)
docile (1.1.5)
minitest (5.8.4)
multi_json (1.10.1)
rake (10.4.2)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-core (3.1.7)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.2)
diff-lcs (1.3)
docile (1.3.1)
json (2.2.0)
minitest (5.11.3)
rake (12.3.2)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
simplecov (0.9.1)
docile (~> 1.1.0)
multi_json (~> 1.0)
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)

PLATFORMS
ruby
Expand All @@ -32,3 +33,6 @@ DEPENDENCIES
rake
rspec
simplecov

BUNDLED WITH
2.0.1
28 changes: 13 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/setup'
require 'bundler/gem_tasks'
require 'rake/testtask'
Expand All @@ -11,29 +13,28 @@ begin
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:refinement) do |task|
task.rspec_opts = "--order rand"
task.pattern = "spec/refinement/*_spec.rb"
task.rspec_opts = '--order rand'
task.pattern = 'spec/refinement/*_spec.rb'
end

RSpec::Core::RakeTask.new(:monkeypatch) do |task|
task.rspec_opts = "--order rand"
task.pattern = "spec/monkeypatch/*_spec.rb"
task.rspec_opts = '--order rand'
task.pattern = 'spec/monkeypatch/*_spec.rb'
end

RSpec::Core::RakeTask.new(:safe) do |task|
task.rspec_opts = "--order rand"
task.pattern = "spec/safe/*_spec.rb"
task.rspec_opts = '--order rand'
task.pattern = 'spec/safe/*_spec.rb'
end

rescue LoadError
warn "rspec unavailable"
warn 'rspec unavailable'
end

task :default do
Rake::Task["test"].invoke
Rake::Task["monkeypatch"].invoke
Rake::Task["safe"].invoke
Rake::Task["refinement"].invoke if ruby_major >= 2 && ruby_minor >= 1
Rake::Task['test'].invoke
Rake::Task['monkeypatch'].invoke
Rake::Task['safe'].invoke
Rake::Task['refinement'].invoke if ruby_major >= 2 && ruby_minor >= 1
end

def ruby_major
Expand All @@ -43,6 +44,3 @@ end
def ruby_minor
RUBY_VERSION.split(/\./)[1].to_i
end



3 changes: 1 addition & 2 deletions descriptive_statistics.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'descriptive_statistics'
s.version = '2.5.1'
s.version = '2.5.2'
Copy link
Copy Markdown
Owner

@thirtysixthspan thirtysixthspan Jul 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only seeing development changes, not changes to the code of the gem itself, and so no version bump in warranted.

Copy link
Copy Markdown
Author

@Rovel Rovel Jul 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, usually I do that in the patch to track any changes like updates and stuff so people can reference the new version or hold to the last they had running to avoid unwanted gem update at all. but if you prefer I can roll back the version.

s.homepage = 'https://github.com/thirtysixthspan/descriptive_statistics'
s.summary = 'Descriptive Statistics'
s.description = 'Adds descriptive statistics methods to Enumerable module for use on collections or Numeric data'
Expand All @@ -9,4 +9,3 @@ Gem::Specification.new do |s|
s.files = Dir['lib/**/**/*']
s.license = "MIT"
end

Binary file removed pkg/descriptive_statistics-2.5.1.gem
Binary file not shown.
Binary file added pkg/descriptive_statistics-2.5.2.gem
Binary file not shown.
38 changes: 19 additions & 19 deletions test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,64 @@

SimpleCov.command_name 'minitest'

class TestData < MiniTest::Unit::TestCase
class TestData < Minitest::Test

def setup
@data = []
CSV.foreach("test/testdata.csv") do |row|
CSV.foreach('test/testdata.csv') do |row|
@data.push row.map(&:to_f)
end
end

def test_sum
@data.each do |test_case|
assert_equal test_case[0,10].sum.round(6), test_case[10].round(6)
assert_equal test_case[0, 10].sum.round(6), test_case[10].round(6)
end
end

def test_mean
@data.each do |test_case|
assert_equal test_case[0,10].mean.round(6), test_case[11].round(6)
assert_equal test_case[0, 10].mean.round(6), test_case[11].round(6)
end
end

def test_median
@data.each do |test_case|
assert_equal test_case[0,10].median.round(6), test_case[12].round(6)
assert_equal test_case[0, 10].median.round(6), test_case[12].round(6)
end
end

def test_variance
@data.each do |test_case|
assert_equal test_case[0,10].variance.round(6), test_case[13].round(6)
assert_equal test_case[0, 10].variance.round(6), test_case[13].round(6)
end
end

def test_standard_deviation
@data.each do |test_case|
assert_equal test_case[0,10].standard_deviation.round(6), test_case[14].round(6)
assert_equal test_case[0, 10].standard_deviation.round(6), test_case[14].round(6)
end
end

def test_percentile
@data.each do |test_case|
assert_equal test_case[0,10].percentile(0).round(6), test_case[15].round(6)
assert_equal test_case[0,10].percentile(10).round(6), test_case[16].round(6)
assert_equal test_case[0,10].percentile(20).round(6), test_case[17].round(6)
assert_equal test_case[0,10].percentile(30).round(6), test_case[18].round(6)
assert_equal test_case[0,10].percentile(40).round(6), test_case[19].round(6)
assert_equal test_case[0,10].percentile(50).round(6), test_case[20].round(6)
assert_equal test_case[0,10].percentile(60).round(6), test_case[21].round(6)
assert_equal test_case[0,10].percentile(70).round(6), test_case[22].round(6)
assert_equal test_case[0,10].percentile(80).round(6), test_case[23].round(6)
assert_equal test_case[0,10].percentile(90).round(6), test_case[24].round(6)
assert_equal test_case[0,10].percentile(100).round(6), test_case[25].round(6)
assert_equal test_case[0, 10].percentile(0).round(6), test_case[15].round(6)
assert_equal test_case[0, 10].percentile(10).round(6), test_case[16].round(6)
assert_equal test_case[0, 10].percentile(20).round(6), test_case[17].round(6)
assert_equal test_case[0, 10].percentile(30).round(6), test_case[18].round(6)
assert_equal test_case[0, 10].percentile(40).round(6), test_case[19].round(6)
assert_equal test_case[0, 10].percentile(50).round(6), test_case[20].round(6)
assert_equal test_case[0, 10].percentile(60).round(6), test_case[21].round(6)
assert_equal test_case[0, 10].percentile(70).round(6), test_case[22].round(6)
assert_equal test_case[0, 10].percentile(80).round(6), test_case[23].round(6)
assert_equal test_case[0, 10].percentile(90).round(6), test_case[24].round(6)
assert_equal test_case[0, 10].percentile(100).round(6), test_case[25].round(6)
end
end

def test_percentile_rank
@data.each do |test_case|
assert_equal test_case[0,10].percentile_rank(50).round(6), test_case[26].round(6)
assert_equal test_case[0, 10].percentile_rank(50).round(6), test_case[26].round(6)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to see rubocop implemented in this repository. Would you be open to moving any style related changes to a new pull request, one which included the rubocop package and a configuration?

Copy link
Copy Markdown
Author

@Rovel Rovel Jul 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will do that.
Any preference on the rubocop style guide or just the default one, one thing I would suggest is to increase the line size from 80 columns to something bigger specially for the test parts.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I opened the Rubocop PR as you asked, after merge we can work in the style changes 👓

end
end

Expand Down