Skip to content

Commit 2c4b9f9

Browse files
committed
Use assert_in_delta for floating-point comparisons
1 parent 2167636 commit 2c4b9f9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/narray_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ class NArrayTest < Test::Unit::TestCase
142142
assert { a.sum == 29 }
143143
if float_types.include?(dtype)
144144
assert { a.mean == 29.0/6 }
145-
assert { a.var == 13.766666666666669 }
146-
assert { a.stddev == 3.710345895825168 }
147-
assert { a.rms == 5.901977069875258 }
145+
assert_in_delta(a.var, 13.766666666666669, 1e-14)
146+
assert_in_delta(a.stddev, 3.710345895825168, 1e-14)
147+
assert_in_delta(a.rms, 5.901977069875258, 1e-14)
148148
end
149149
assert { a.dup.fill(12) == [12]*6 }
150150
assert { (a + 1) == [2,3,4,6,8,12] }

0 commit comments

Comments
 (0)