Skip to content

Instantly share code, notes, and snippets.

@bhumpert
Last active July 29, 2016 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhumpert/8af0ba7b6d50864b1e5e to your computer and use it in GitHub Desktop.
Save bhumpert/8af0ba7b6d50864b1e5e to your computer and use it in GitHub Desktop.
In [23]: def test_17(n):
....: for _ in range(n):
....: x = random()
....: assert x == float('{:1.16e}'.format(x))
....: print('Test success')
....:
In [24]: test_17(1000000)
Test success
In [27]: def test_16(n):
for _ in range(n):
x = random()
assert x == float('{:1.15e}'.format(x))
print('Test success')
....:
In [28]: test_16(1000000)
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-28-f4fed7690d1e> in <module>()
----> 1 test_16(1000000)
<ipython-input-27-d3a9aed9c7ce> in test_16(n)
2 for _ in range(n):
3 x = random()
----> 4 assert x == float('{:1.15e}'.format(x))
5 print('Test success')
6
AssertionError:
@yjhuoh
Copy link

yjhuoh commented Jul 29, 2016

i remember this gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment