MAINT: use asset_allclose instead of round

This commit is contained in:
François Boulogne
2014-03-15 07:58:01 -04:00
parent ee12ccff26
commit a423bd15e6
+6 -6
View File
@@ -102,18 +102,18 @@ def test_ellipsoid_levelset():
def test_ellipsoid_stats():
# Test comparison values generated by Wolfram Alpha
vol, surf = ellipsoid_stats(6, 10, 16)
assert(round(1280 * np.pi, 4) == round(vol, 4))
assert(1383.28 == round(surf, 2))
assert_allclose(1280 * np.pi, vol, atol=1e-4)
assert_allclose(1383.28, surf, atol=1e-2)
# Test when a <= b <= c does not hold
vol, surf = ellipsoid_stats(16, 6, 10)
assert(round(1280 * np.pi, 4) == round(vol, 4))
assert(1383.28 == round(surf, 2))
assert_allclose(1280 * np.pi, vol, atol=1e-4))
assert_allclose(1383.28, surf, atol=1e-2)
# Larger test to ensure reliability over broad range
vol, surf = ellipsoid_stats(17, 27, 169)
assert(round(103428 * np.pi, 4) == round(vol, 4))
assert(37426.3 == round(surf, 1))
assert_allclose(103428 * np.pi, vol, atol=1e-4))
assert_allclose(37426.3, surf, atol=1e-1)
if __name__ == "__main__":