[TCHECK-74] gen-int generates very small ints Created: 02/Jul/15 Updated: 02/Jul/15
|Reporter:||Jonathan Leonard||Assignee:||Reid Draper|
Sorry for creating an issue for this but I couldn't find any way to communicate with the developers of this project otherwise. Can someone explain why taking 100,000 ints never yields an int larger than 100? Is it due to the 'size' parameter? Does the runtime just adjust 'size' on the fly to reach 2.7 billion or what not?
If manually sampling a generator, how can one adjust the size?
|Comment by Gary Fredericks [ 02/Jul/15 3:22 PM ]|
This is a pretty major gotcha currently, and one that definitely would have been fixed by now if there was an obvious best way to fix it.
See the "Numerics" section of this page if you're interested in my ideas for fixing it.
Fortunately there's nothing blocking you from generating what you want once you understand how the pieces work together.
By default the size parameter ranges from 0-200 in normal testing (even smaller if you run your tests less than 200 times at once), which means that gen/int and similar generators stay quite small.
There are at least a couple options for opting-in to larger numbers currently:
As for setting the size when sampling, I recommend the new gen/generate function, which takes an optional size argument.
|Comment by Gary Fredericks [ 02/Jul/15 3:23 PM ]|
I was looking for another ticket on this topic since I figured one must exist, but I didn't find it. So I'll probably leave this ticket open as a representative of the broader numerics issue.
|Comment by Jonathan Leonard [ 02/Jul/15 4:24 PM ]|
Thanks for the reply/explanation.
However, doesn't the `gen/scale` solution still have the drawback that it will be biased towards larger numbers-- i.e., it will be impossible to return integers between 1 and 9999 in your example code.
|Comment by Gary Fredericks [ 02/Jul/15 8:23 PM ]|
The distribution should be a uniform range of size roughly (* 10000 size), so small numbers are definitely possible: