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

Generating integers #35

Open
effectfully opened this issue Oct 9, 2019 · 3 comments
Open

Generating integers #35

effectfully opened this issue Oct 9, 2019 · 3 comments
Labels

Comments

@effectfully
Copy link
Owner

Previously we only needed to generate integers in comparisons, but now we have plenty of places where it would be useful to generate integers. I'm now getting test failures only with the F17 field, because the Arbitrary instance of Rational is just extremely unlikely to produce an integer at all:

arbitrarySizedFractional :: Fractional a => Gen a
arbitrarySizedFractional =
  sized $ \n ->
    let n' = toInteger n in
      do b <- choose (1, precision)
         a <- choose ((-n') * b, n' * b)
         return (fromRational (a % b))
 where
  precision = 9999999999999 :: Integer

instance Integral a => Arbitrary (Ratio a) where
  arbitrary = arbitrarySizedFractional

This begs to be resolved.

@effectfully
Copy link
Owner Author

effectfully commented Oct 9, 2019

Changed the field elements generator in 967a8b0 to

Field  -> frequency
    [ (2, fromIntegral <$> arbitrarySizedBoundedIntegral @Int)
    , (1, arbitrary)
    ]

Now we produce integer-valued field elements pretty often. Not sure why we didn't do this earlier.

@effectfully
Copy link
Owner Author

Made it

Field  -> frequency
    [ (1, fromIntegral <$> arbitrary @Int)
    , (1, fromIntegral <$> arbitrarySizedBoundedIntegral @Int)
    , (1, arbitrary)
    ]

in b02791e so that fairly small integers also get generated.

@effectfully
Copy link
Owner Author

Whenever we generate assert x < i we should also generate values for x less than i most of the time.

@effectfully effectfully changed the title Generaring integers Generating integers Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant