Replies: 1 comment 1 reply
-
I think math.isfinite() in preconditions is fine |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As of v0.0.58, CrossHair can generate
math.nan
,math.inf
, and-math.inf
as float arguments.The only officially supported way to avoid this is to add
math.isfinite()
preconditions. But there might be other options.I'm slightly -1 on having global or broad configuration to disable this behavior - it hurts readability and reproduce-ability to have hidden state that changes the meaning of the contract or test.
If some day, CrossHair understands annotated-types, then you could write this in a less verbose way as part of the type annotation, e.g.:
def foo(x: IsFinite[float]):
Who has other options or ideas?
Beta Was this translation helpful? Give feedback.
All reactions