Skip to content

Commit 0ac0c49

Browse files
committed
adding test to check hash function for float)
1 parent 349d954 commit 0ac0c49

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pydra/engine/tests/test_helpers.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,25 @@ def test_hash_file(tmpdir):
5050
helpers_file.hash_file(outdir / "test.file")
5151
== "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
5252
)
53+
54+
55+
def test_hashfun_float():
56+
import math
57+
58+
pi_50 = 3.14159265358979323846264338327950288419716939937510
59+
pi_15 = 3.141592653589793
60+
pi_10 = 3.1415926536
61+
# comparing for x that have the same x.as_integer_ratio()
62+
assert (
63+
math.pi.as_integer_ratio()
64+
== pi_50.as_integer_ratio()
65+
== pi_15.as_integer_ratio()
66+
)
67+
assert (
68+
helpers.hash_function(math.pi)
69+
== helpers.hash_function(pi_15)
70+
== helpers.hash_function(pi_50)
71+
)
72+
# comparing for x that have different x.as_integer_ratio()
73+
assert math.pi.as_integer_ratio() != pi_10.as_integer_ratio()
74+
assert helpers.hash_function(math.pi) != helpers.hash_function(pi_10)

0 commit comments

Comments
 (0)