Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Ruby 3.3 #16

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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 .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 3.3.1
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: ruby
rvm:
- 1.9.3
- 3.3.1
script: "rake spec"
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source :gemcutter
source "https://rubygems.org"

gem 'rake'
gem 'rspec'
Expand Down
46 changes: 28 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
bluecloth (2.2.0)
diff-lcs (1.1.3)
multi_json (1.3.6)
rake (0.9.2.2)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.2)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.2)
simplecov (0.6.4)
multi_json (~> 1.0)
simplecov-html (~> 0.5.3)
simplecov-html (0.5.3)
yard (0.8.2.1)
diff-lcs (1.5.1)
docile (1.4.0)
rake (13.2.1)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
yard (0.9.36)
yard-rspec (0.1)
yard

PLATFORMS
ruby
x86_64-darwin-23

DEPENDENCIES
bluecloth
Expand All @@ -31,3 +38,6 @@ DEPENDENCIES
simplecov
yard
yard-rspec

BUNDLED WITH
2.4.10
66 changes: 33 additions & 33 deletions spec/saulabs/gauss/distribution_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
describe Gauss::Distribution, "#initialize" do

it "should set the mean to 10.1" do
Gauss::Distribution.new(10.1, 0.4).mean.should == 10.1
expect(Gauss::Distribution.new(10.1, 0.4).mean).to eq(10.1)
end

it "should set the deviation to 0.4" do
Gauss::Distribution.new(10.1, 0.4).deviation.should == 0.4
expect(Gauss::Distribution.new(10.1, 0.4).deviation).to eq(0.4)
end

it "should set the mean to 0.0 if the given mean is not finite" do
Gauss::Distribution.new(1 / 0.0, 0.4).mean.should == 0.0
expect(Gauss::Distribution.new(1 / 0.0, 0.4).mean).to eq(0.0)
end

it "should set the deviation to 0.0 if the given deviation is not finite" do
Gauss::Distribution.new(10.1, 1 / 0.0).deviation.should == 0.0
expect(Gauss::Distribution.new(10.1, 1 / 0.0).deviation).to eq(0.0)
end

end
Expand All @@ -28,23 +28,23 @@
end

it "should have a default mean value of 25.0" do
@dist.mean.should == 25.0
expect(@dist.mean).to eq(25.0)
end

it "should have a default deviation of 8.333333" do
@dist.deviation.should be_within(0.000001).of(8.333333)
expect(@dist.deviation).to be_within(0.000001).of(8.333333)
end

it "should set the variance to 69.444438" do
@dist.variance.should be_within(0.0001).of(69.4444)
expect(@dist.variance).to be_within(0.0001).of(69.4444)
end

it "should set the precision to 0.0144" do
@dist.precision.should be_within(0.0001).of(0.0144)
expect(@dist.precision).to be_within(0.0001).of(0.0144)
end

it "should set the precision_mean to 0.36" do
@dist.precision_mean.should be_within(0.0001).of(0.36)
expect(@dist.precision_mean).to be_within(0.0001).of(0.36)
end

end
Expand All @@ -56,23 +56,23 @@
end

it "should have a default mean value of 25.0" do
@dist.mean.should == 25.0
expect(@dist.mean).to eq(25.0)
end

it "should have a default deviation of 8.333333" do
@dist.deviation.should be_within(0.000001).of(8.333333)
expect(@dist.deviation).to be_within(0.000001).of(8.333333)
end

it "should set the variance to 69.444438" do
@dist.variance.should be_within(0.0001).of(69.4444)
expect(@dist.variance).to be_within(0.0001).of(69.4444)
end

it "should set the precision to 0.0144" do
@dist.precision.should be_within(0.0001).of(0.0144)
expect(@dist.precision).to be_within(0.0001).of(0.0144)
end

it "should set the precision_mean to 0.36" do
@dist.precision_mean.should be_within(0.0001).of(0.36)
expect(@dist.precision_mean).to be_within(0.0001).of(0.36)
end

end
Expand All @@ -84,35 +84,35 @@
end

it "should be 0.0 for the same distribution" do
(@dist - @dist).should == 0.0
expect(@dist - @dist).to eq(0.0)
end

it "should equal the precision mean if the 0-distribution is subtracted" do
(@dist - Gauss::Distribution.new).should == @dist.precision_mean
expect(@dist - Gauss::Distribution.new).to eq(@dist.precision_mean)
end

it "should be 130.399408 for (22, 0.4) - (12, 1.3)" do
(Gauss::Distribution.new(22, 0.4) - Gauss::Distribution.new(12, 1.3)).should be_within(tolerance).of(130.399408)
expect(Gauss::Distribution.new(22, 0.4) - Gauss::Distribution.new(12, 1.3)).to be_within(tolerance).of(130.399408)
end

end

describe Gauss::Distribution, "#value_at" do

it "should have a value of 0.073654 for x = 2" do
Gauss::Distribution.new(4,5).value_at(2).should be_within(tolerance).of(0.073654)
expect(Gauss::Distribution.new(4,5).value_at(2)).to be_within(tolerance).of(0.073654)
end

end

describe Gauss::Distribution, "multiplication (*)" do

it "should have a mean of 0.2" do
(Gauss::Distribution.new(0,1) * Gauss::Distribution.new(2,3)).mean.should be_within(0.00001).of(0.2)
expect((Gauss::Distribution.new(0,1) * Gauss::Distribution.new(2,3)).mean).to be_within(0.00001).of(0.2)
end

it "should have a deviation of 3.0 / Math.sqrt(10)" do
(Gauss::Distribution.new(0,1) * Gauss::Distribution.new(2,3)).deviation.should be_within(0.00001).of(3.0 / Math.sqrt(10))
expect((Gauss::Distribution.new(0,1) * Gauss::Distribution.new(2,3)).deviation).to be_within(0.00001).of(3.0 / Math.sqrt(10))
end

end
Expand All @@ -121,7 +121,7 @@

it "should have calculate -3.0979981" do
lp = Gauss::Distribution.log_product_normalization(Gauss::Distribution.new(4,5), Gauss::Distribution.new(6,7))
lp.should be_within(0.000001).of(-3.0979981)
expect(lp).to be_within(0.000001).of(-3.0979981)
end

end
Expand All @@ -131,44 +131,44 @@
describe 'value = 0.27' do

it "#cumulative_distribution_function should return 0.6064198 for 0.27" do
Gauss::Distribution.cumulative_distribution_function(0.27).should be_within(0.00001).of(0.6064198)
Gauss::Distribution.cdf(2.0).should be_within(0.00001).of(0.9772498)
expect(Gauss::Distribution.cumulative_distribution_function(0.27)).to be_within(0.00001).of(0.6064198)
expect(Gauss::Distribution.cdf(2.0)).to be_within(0.00001).of(0.9772498)
end

it "#probability_density_function should return 0.384662" do
Gauss::Distribution.probability_density_function(0.27).should be_within(0.0001).of(0.384662)
expect(Gauss::Distribution.probability_density_function(0.27)).to be_within(0.0001).of(0.384662)
end

it "#quantile_function should return ~ -0.6128123 at 0.27" do
Gauss::Distribution.quantile_function(0.27).should be_within(0.00001).of(-0.6128123)
expect(Gauss::Distribution.quantile_function(0.27)).to be_within(0.00001).of(-0.6128123)
end

it "#quantile_function should return ~ 1.281551 at 0.9" do
Gauss::Distribution.quantile_function(0.9).should be_within(0.00001).of(1.281551)
expect(Gauss::Distribution.quantile_function(0.9)).to be_within(0.00001).of(1.281551)
end

it "#erf_inv should return 0.0888559 at 0.9" do
Gauss::Distribution.inv_erf(0.9).should be_within(0.00001).of(0.0888559)
expect(Gauss::Distribution.inv_erf(0.9)).to be_within(0.00001).of(0.0888559)
end

it "#erf_inv should return 0.779983 at 0.27" do
Gauss::Distribution.inv_erf(0.27).should be_within(0.00001).of(0.779983)
expect(Gauss::Distribution.inv_erf(0.27)).to be_within(0.00001).of(0.779983)
end

it "#erf_inv should return 100 at -0.5" do
Gauss::Distribution.inv_erf(-0.5).should be_within(0.00001).of(100)
expect(Gauss::Distribution.inv_erf(-0.5)).to be_within(0.00001).of(100)
end

it "#erf should return 0.203091 at 0.9" do
Gauss::Distribution.erf(0.9).should be_within(0.00001).of(0.203091)
expect(Gauss::Distribution.erf(0.9)).to be_within(0.00001).of(0.203091)
end

it "#erf should return 0.702581 at 0.27" do
Gauss::Distribution.erf(0.27).should be_within(0.00001).of(0.702581)
expect(Gauss::Distribution.erf(0.27)).to be_within(0.00001).of(0.702581)
end

it "#erf should return 1.520499 at -0.5" do
Gauss::Distribution.erf(-0.5).should be_within(0.00001).of(1.520499)
expect(Gauss::Distribution.erf(-0.5)).to be_within(0.00001).of(1.520499)
end

end
Expand All @@ -184,7 +184,7 @@

it "should be equal to the replaced distribution" do
@dist1.replace(@dist2)
@dist1.should == @dist2
expect(@dist1).to eq(@dist2)
end

end
20 changes: 10 additions & 10 deletions spec/saulabs/gauss/truncated_correction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@
describe "#w_within_margin" do

it "should return 0.970397 for (0.2, 0.3)" do
Gauss::TruncatedCorrection.w_within_margin(0.2, 0.3).should be_within(tolerance).of(0.970397)
Gauss::TruncatedCorrection.w_within_margin(0.1, 0.03).should be_within(tolerance).of(0.9997)
expect(Gauss::TruncatedCorrection.w_within_margin(0.2, 0.3)).to be_within(tolerance).of(0.970397)
expect(Gauss::TruncatedCorrection.w_within_margin(0.1, 0.03)).to be_within(tolerance).of(0.9997)
end

end

describe "#v_within_margin" do

it "should return -0.194073 for (0.2, 0.3)" do
Gauss::TruncatedCorrection.v_within_margin(0.2, 0.3).should be_within(tolerance).of(-0.194073)
Gauss::TruncatedCorrection.v_within_margin(0.1, 0.03).should be_within(tolerance).of(-0.09997)
expect(Gauss::TruncatedCorrection.v_within_margin(0.2, 0.3)).to be_within(tolerance).of(-0.194073)
expect(Gauss::TruncatedCorrection.v_within_margin(0.1, 0.03)).to be_within(tolerance).of(-0.09997)
end

end

describe "#w_exceeds_margin" do

it "should return 0.657847 for (0.2, 0.3)" do
Gauss::TruncatedCorrection.w_exceeds_margin(0.0, 0.740466).should be_within(tolerance).of(0.76774506)
Gauss::TruncatedCorrection.w_exceeds_margin(0.2, 0.3).should be_within(tolerance).of(0.657847)
Gauss::TruncatedCorrection.w_exceeds_margin(0.1, 0.03).should be_within(tolerance).of(0.621078)
expect(Gauss::TruncatedCorrection.w_exceeds_margin(0.0, 0.740466)).to be_within(tolerance).of(0.76774506)
expect(Gauss::TruncatedCorrection.w_exceeds_margin(0.2, 0.3)).to be_within(tolerance).of(0.657847)
expect(Gauss::TruncatedCorrection.w_exceeds_margin(0.1, 0.03)).to be_within(tolerance).of(0.621078)
end

end

describe "#v_exceeds_margin" do

it "should return 0.8626174 for (0.2, 0.3)" do
Gauss::TruncatedCorrection.v_exceeds_margin(0.0, 0.740466).should be_within(tolerance).of(1.32145197)
Gauss::TruncatedCorrection.v_exceeds_margin(0.2, 0.3).should be_within(tolerance).of(0.8626174)
Gauss::TruncatedCorrection.v_exceeds_margin(0.1, 0.03).should be_within(tolerance).of(0.753861)
expect(Gauss::TruncatedCorrection.v_exceeds_margin(0.0, 0.740466)).to be_within(tolerance).of(1.32145197)
expect(Gauss::TruncatedCorrection.v_exceeds_margin(0.2, 0.3)).to be_within(tolerance).of(0.8626174)
expect(Gauss::TruncatedCorrection.v_exceeds_margin(0.1, 0.03)).to be_within(tolerance).of(0.753861)
end

end
Expand Down
Loading