Permalink
Browse files

RSpec deprectation (be_within instead of be_close)

  • Loading branch information...
1 parent c77daa2 commit 4df54338ebda092087b0b0472288284003884831 @mk mk committed Aug 15, 2012
@@ -32,19 +32,19 @@
end
it "should have a default deviation of 8.333333" do
- @dist.deviation.should be_close(8.333333, 0.000001)
+ @dist.deviation.should be_within(0.000001).of(8.333333)
end
it "should set the variance to 69.444438" do
- @dist.variance.should be_close(69.4444, 0.0001)
+ @dist.variance.should be_within(0.0001).of(69.4444)
end
it "should set the precision to 0.0144" do
- @dist.precision.should be_close(0.0144, 0.0001)
+ @dist.precision.should be_within(0.0001).of(0.0144)
end
it "should set the precision_mean to 0.36" do
- @dist.precision_mean.should be_close(0.36, 0.0001)
+ @dist.precision_mean.should be_within(0.0001).of(0.36)
end
end
@@ -60,19 +60,19 @@
end
it "should have a default deviation of 8.333333" do
- @dist.deviation.should be_close(8.333333, 0.000001)
+ @dist.deviation.should be_within(0.000001).of(8.333333)
end
it "should set the variance to 69.444438" do
- @dist.variance.should be_close(69.4444, 0.0001)
+ @dist.variance.should be_within(0.0001).of(69.4444)
end
it "should set the precision to 0.0144" do
- @dist.precision.should be_close(0.0144, 0.0001)
+ @dist.precision.should be_within(0.0001).of(0.0144)
end
it "should set the precision_mean to 0.36" do
- @dist.precision_mean.should be_close(0.36, 0.0001)
+ @dist.precision_mean.should be_within(0.0001).of(0.36)
end
end
@@ -92,27 +92,27 @@
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_close(130.399408, tolerance)
+ (Gauss::Distribution.new(22, 0.4) - Gauss::Distribution.new(12, 1.3)).should 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_close(0.073654, tolerance)
+ Gauss::Distribution.new(4,5).value_at(2).should 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_close(0.2, 0.00001)
+ (Gauss::Distribution.new(0,1) * Gauss::Distribution.new(2,3)).mean.should 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_close(3.0 / Math.sqrt(10), 0.00001)
+ (Gauss::Distribution.new(0,1) * Gauss::Distribution.new(2,3)).deviation.should be_within(0.00001).of(3.0 / Math.sqrt(10))
end
end
@@ -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_close(-3.0979981, 0.000001)
+ lp.should be_within(0.000001).of(-3.0979981)
end
end
@@ -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_close(0.6064198, 0.00001)
- Gauss::Distribution.cdf(2.0).should be_close(0.9772498, 0.00001)
+ 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)
end
it "#probability_density_function should return 0.384662" do
- Gauss::Distribution.probability_density_function(0.27).should be_close(0.384662, 0.0001)
+ Gauss::Distribution.probability_density_function(0.27).should 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_close(-0.6128123, 0.00001)
+ Gauss::Distribution.quantile_function(0.27).should 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_close(1.281551, 0.00001)
+ Gauss::Distribution.quantile_function(0.9).should 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_close(0.0888559, 0.00001)
+ Gauss::Distribution.inv_erf(0.9).should 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_close(0.779983, 0.00001)
+ Gauss::Distribution.inv_erf(0.27).should 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_close(100, 0.00001)
+ Gauss::Distribution.inv_erf(-0.5).should be_within(0.00001).of(100)
end
it "#erf should return 0.203091 at 0.9" do
- Gauss::Distribution.erf(0.9).should be_close(0.203091, 0.00001)
+ Gauss::Distribution.erf(0.9).should 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_close(0.702581, 0.00001)
+ Gauss::Distribution.erf(0.27).should 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_close(1.520499, 0.00001)
+ Gauss::Distribution.erf(-0.5).should be_within(0.00001).of(1.520499)
end
end
@@ -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_close(0.970397, tolerance)
- Gauss::TruncatedCorrection.w_within_margin(0.1, 0.03).should be_close(0.9997, tolerance)
+ 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)
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_close(-0.194073, tolerance)
- Gauss::TruncatedCorrection.v_within_margin(0.1, 0.03).should be_close(-0.09997, tolerance)
+ 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)
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_close(0.76774506, tolerance)
- Gauss::TruncatedCorrection.w_exceeds_margin(0.2, 0.3).should be_close(0.657847, tolerance)
- Gauss::TruncatedCorrection.w_exceeds_margin(0.1, 0.03).should be_close(0.621078, tolerance)
+ 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)
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_close(1.32145197, tolerance)
- Gauss::TruncatedCorrection.v_exceeds_margin(0.2, 0.3).should be_close(0.8626174, tolerance)
- Gauss::TruncatedCorrection.v_exceeds_margin(0.1, 0.03).should be_close(0.753861, tolerance)
+ 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)
end
end
@@ -13,20 +13,20 @@
it "should update the mean of the first player in team1 to 30.38345" do
@graph.update_skills
- @skill.mean.should be_close(30.38345, tolerance)
+ @skill.mean.should be_within(tolerance).of(30.38345)
end
it "should update the deviation of the first player in team1 to 3.46421" do
@graph.update_skills
- @skill.deviation.should be_close(3.46421, tolerance)
+ @skill.deviation.should be_within(tolerance).of(3.46421)
end
end
describe "#draw_margin" do
it "should be -0.998291 for diff 0.740466" do
- @graph.draw_margin.should be_close(0.740466, tolerance)
+ @graph.draw_margin.should be_within(tolerance).of(0.740466)
end
end
@@ -11,15 +11,15 @@
describe "#update_message_at" do
it "should return a difference of 2.1409" do
- @factor.update_message_at(0).should be_close(2.1409, tolerance)
+ @factor.update_message_at(0).should be_within(tolerance).of(2.1409)
end
end
describe "#log_normalization" do
it "should be -0.69314" do
- @factor.log_normalization.should be_close(-0.69314, tolerance)
+ @factor.log_normalization.should be_within(tolerance).of(-0.69314)
end
end
@@ -12,12 +12,12 @@
describe "#update_message_at" do
it "should return a difference of 0.0" do
- @factor.update_message_at(0).should be_close(0.0, tolerance)
+ @factor.update_message_at(0).should be_within(tolerance).of(0.0)
end
it "should return a difference of 0.833066 for the second message" do
@factor.update_message_at(0)
- @factor.update_message_at(1).should be_close(0.833066, tolerance)
+ @factor.update_message_at(1).should be_within(tolerance).of(0.833066)
end
end
@@ -11,7 +11,7 @@
describe "#update_message_at" do
it "should return a difference of 73.33333" do
- @factor.update_message_at(0).should be_close(73.33333, tolerance)
+ @factor.update_message_at(0).should be_within(tolerance).of(73.33333)
end
end
@@ -16,25 +16,25 @@
describe "weights" do
it "should setup the weights correctly" do
- @factor.weights[0][0].should be_close(0.5, tolerance)
- @factor.weights[1][0].should be_close(-1.4, tolerance)
- @factor.weights[2][0].should be_close(-0.7142, tolerance)
- @factor.weights[2][1].should be_close(-1.14285, tolerance)
- @factor.weights[3][0].should be_close(-0.625, tolerance)
- @factor.weights[3][2].should be_close(1.25, tolerance)
+ @factor.weights[0][0].should be_within(tolerance).of(0.5)
+ @factor.weights[1][0].should be_within(tolerance).of(-1.4)
+ @factor.weights[2][0].should be_within(tolerance).of(-0.7142)
+ @factor.weights[2][1].should be_within(tolerance).of(-1.14285)
+ @factor.weights[3][0].should be_within(tolerance).of(-0.625)
+ @factor.weights[3][2].should be_within(tolerance).of(1.25)
end
end
describe "weights_squared" do
it "should setup the squared weights correctly" do
- @factor.weights_squared[0][0].should be_close(0.25, tolerance)
- @factor.weights_squared[1][0].should be_close(1.96, tolerance)
- @factor.weights_squared[2][0].should be_close(0.51, tolerance)
- @factor.weights_squared[2][1].should be_close(1.3061, tolerance)
- @factor.weights_squared[3][0].should be_close(0.3906, tolerance)
- @factor.weights_squared[3][2].should be_close(1.5625, tolerance)
+ @factor.weights_squared[0][0].should be_within(tolerance).of(0.25)
+ @factor.weights_squared[1][0].should be_within(tolerance).of(1.96)
+ @factor.weights_squared[2][0].should be_within(tolerance).of(0.51)
+ @factor.weights_squared[2][1].should be_within(tolerance).of(1.3061)
+ @factor.weights_squared[3][0].should be_within(tolerance).of(0.3906)
+ @factor.weights_squared[3][2].should be_within(tolerance).of(1.5625)
end
end
@@ -55,7 +55,7 @@
describe "#update_message_at" do
it "should return a difference of 4.50116 for message 0" do
- @factor.update_message_at(0).should be_close(4.50116, tolerance)
+ @factor.update_message_at(0).should be_within(tolerance).of(4.50116)
end
end
@@ -11,15 +11,15 @@
describe "#update_message_at" do
it "should return a difference of 173.2048" do
- @factor.update_message_at(0).should be_close(173.2048, tolerance)
+ @factor.update_message_at(0).should be_within(tolerance).of(173.2048)
end
end
describe "#log_normalization" do
it "should be -5.339497" do
- @factor.log_normalization.should be_close(-5.339497, tolerance)
+ @factor.log_normalization.should be_within(tolerance).of(-5.339497)
end
end

0 comments on commit 4df5433

Please sign in to comment.