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

[doc] Guard values with "ti.approx" in "docs/write_test.rst" to allow FP-error tolerance #1911

Merged
merged 7 commits into from
Oct 3, 2020
12 changes: 6 additions & 6 deletions docs/write_test.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ We may test against different input values using the ``@pytest.mark.parametrize`

r[None] = x
foo()
assert r[None] == math.log10(x)
assert ti.approx(r[None]) == math.log10(x)

Use a comma-separated list for multiple input values:

Expand All @@ -174,10 +174,10 @@ Use a comma-separated list for multiple input values:
def foo():
r[None] = ti.atan2(r[None], s[None])

r[None] = x
s[None] = y
r[None] = y
s[None] = x
foo()
assert r[None] == math.atan2(y, x)
assert ti.approx(r[None]) == math.atan2(y, x)

Use two separate ``parametrize`` to test **all combinations** of input arguments:

Expand All @@ -187,8 +187,8 @@ Use two separate ``parametrize`` to test **all combinations** of input arguments
import pytest
import math

@pytest.mark.parametrize('x', [1, 2])
@pytest.mark.parametrize('y', [1, 2])
@pytest.mark.parametrize('x', [1, 2])
# same as: .parametrize('y,x', [(1, 1), (1, 2), (2, 1), (2, 2)])
@ti.test()
def test_atan2(y, x):
Expand All @@ -202,7 +202,7 @@ Use two separate ``parametrize`` to test **all combinations** of input arguments
r[None] = y
s[None] = x
foo()
assert r[None] == math.atan2(y, x)
assert ti.approx(r[None]) == math.atan2(y, x)

Specifying ``ti.init`` configurations
*************************************
Expand Down