Skip to content

Commit

Permalink
math.isfinite is only in Python 3 (still 1.0.3).
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski committed Sep 22, 2016
1 parent dc23bce commit 496b83a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/testspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ def stripNames(x):
stripNames(xi)

for testresult in testresults:
testresult["expr"] = testresult["expr"].replace('"round(withholes)"', 'named("round(withholes)", lambda x: round(x["withholes"]) if math.isfinite(x["withholes"]) else x["withholes"])')
testresult["expr"] = testresult["expr"].replace('"[round(withholes), 2*round(withholes), 3*round(withholes)]"', 'named("[round(withholes), 2*round(withholes), 3*round(withholes)]", lambda x: [round(x["withholes"]), 2*round(x["withholes"]), 3*round(x["withholes"])] if math.isfinite(x["withholes"]) else [x["withholes"], x["withholes"], x["withholes"]])')
if hasattr(math, "isfinite"):
testresult["expr"] = testresult["expr"].replace('"round(withholes)"', 'named("round(withholes)", lambda x: round(x["withholes"]) if math.isfinite(x["withholes"]) else x["withholes"])')
testresult["expr"] = testresult["expr"].replace('"[round(withholes), 2*round(withholes), 3*round(withholes)]"', 'named("[round(withholes), 2*round(withholes), 3*round(withholes)]", lambda x: [round(x["withholes"]), 2*round(x["withholes"]), 3*round(x["withholes"])] if math.isfinite(x["withholes"]) else [x["withholes"], x["withholes"], x["withholes"]])')

sys.stderr.write(testresult["expr"] + "\n")

Expand Down

0 comments on commit 496b83a

Please sign in to comment.