Skip to content

Commit

Permalink
NF: test thresh for fp error in fill_positive
Browse files Browse the repository at this point in the history
Test that floating point error checked and adjusted in fill_positive.
  • Loading branch information
matthew-brett committed Jan 9, 2015
1 parent e6b69f0 commit 0782e80
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion transforms3d/tests/test_quaternions.py
Expand Up @@ -49,7 +49,15 @@ def test_fillpos():
# Errors with negative w2
assert_raises(ValueError, tq.fillpositive, [1.0]*3)
# Test corner case where w is near zero
wxyz = tq.fillpositive([1,0,0])
wxyz = tq.fillpositive([1, 0, 0])
assert_equal(wxyz[0], 0.0)
eps = np.finfo(float).eps
wxyz = tq.fillpositive([1 + eps, 0, 0])
assert_equal(wxyz[0], 0.0)
# Bump up the floating point error - raises error
assert_raises(ValueError, tq.fillpositive, [1 + eps * 3, 0, 0])
# Increase threshold, happy again
wxyz = tq.fillpositive([1 + eps * 3, 0, 0], w2_thresh=eps * -10)
assert_equal(wxyz[0], 0.0)


Expand Down

0 comments on commit 0782e80

Please sign in to comment.