mitch
09/11/2020, 9:29 PMArb.distinct
what’s the actual intention behind that? i.e. what’s the behaviour that you would expect if that arb is called? Am i understanding this right?
for any given arbitraries, return a uniformly distributed random elements based on a selectoras in, if the input arb yields
[1, 1, 1, 1, 1, 1, 1, 2]
, the distinct arb would yield [1, 2, 1, 1, 2, 1, 2, 2]
or something like that with equal sampling probability of 1
and 2
2. are you still keen on introducing Edgecases<A> for the combinatorial edgecases? I’m still working on that atm, but will only proceed if you are.LeoColman
09/11/2020, 9:38 PMmitch
09/11/2020, 9:50 PMsequence.distinct
currently hangs is it’s trying to loop until it exhausts the whole population of the input arb (which is an infinite sequence)sam
09/11/2020, 10:16 PMsam
09/11/2020, 10:17 PM<http://Arb.int|Arb.int>().distinct()
you will get random ints, but you won't get the same one twice in a runsam
09/11/2020, 10:17 PMmitch
09/11/2020, 10:18 PMmitch
09/11/2020, 10:19 PMmitch
09/11/2020, 10:20 PMmitch
09/11/2020, 10:22 PMsam
09/11/2020, 10:27 PMsequence { yield(1) }.distinct().take(2)
mitch
09/11/2020, 10:35 PMsam
09/11/2020, 10:37 PMmitch
09/11/2020, 10:39 PMsam
09/11/2020, 10:40 PMmitch
09/11/2020, 10:41 PMsam
09/11/2020, 10:41 PMsam
09/11/2020, 10:41 PMmitch
09/11/2020, 10:42 PMsam
09/11/2020, 10:43 PMsam
09/11/2020, 10:44 PM<http://Arb.int|Arb.int>().distinct()
you can have a max of Integer.Max - Integer.Min valuessam
09/11/2020, 10:44 PM<http://Arb.int|Arb.int>(0..1000).distinct()
can only be used in a method that asks for at most 1000 iterationssam
09/11/2020, 10:45 PMsam
09/11/2020, 10:45 PM.map { 0 }
now I have a sample space of 1mitch
09/11/2020, 10:49 PMsam
09/11/2020, 10:49 PMmitch
09/11/2020, 10:50 PMmitch
09/11/2020, 10:50 PMsam
09/11/2020, 10:51 PM<http://Arb.int|Arb.int>().filter ( it == 0 }.exhaustive()
can't return ?mitch
09/11/2020, 10:52 PMmitch
09/11/2020, 10:52 PMsam
09/11/2020, 10:52 PMarb.toExhaustive(requiredSize, maxValues)
which will pull at most maxValues to generate requiredSize, and will error if you don't get there.sam
09/11/2020, 10:53 PMsam
09/11/2020, 10:54 PM<http://Arb.int|Arb.int>().exhaustive(1000, 2000)
tries to up 2000 values to get an Exhaustive of 1000 values taken from the int arbsam
09/11/2020, 10:56 PMfun Arb.Companion.toExhaustive(size) = toExhaustive(size, size * 2
sam
09/11/2020, 10:56 PMsam
09/11/2020, 10:57 PMsam
09/11/2020, 10:57 PMDistinct
which is a group of randomized, but never repeated valuessam
09/11/2020, 11:00 PMArb
- infinite, random
Exhaustive
infinite, predictable, has min iteration requirement
`Distinct`finite, random, has max iteration value due to being finitemitch
09/11/2020, 11:32 PMmitch
09/12/2020, 12:10 AM- infinite, randomArb
infinite, predictable, has min iteration requirementExhaustive
`Distinct`finite, random, has max iteration value due to being finite (edited)🤔
sam
09/12/2020, 1:07 AMsam
09/12/2020, 1:08 AMmitch
09/12/2020, 12:08 PMfun <A, B> Arb<A>.distinctExhaustive(sampleSize: Int = 1000, rs: RandomSource = RandomSource.Default, selector: (A) -> B): Exhaustive<A> =
exhaustive(
this.generate(rs).take(sampleSize).map { it.value }
.toList()
.distinctBy(selector) // :tada:
)
🙈
rebalanced arbs
fun <A, B> Arb<A>.distinctBy(sampleSize: Int = 1000, selector: (A) -> B): Arb<A> =
Arb.list(this, (sampleSize-1)..sampleSize)
.flatMap { listA: List<A> ->
Arb.of(listA.distinctBy(selector))
}
err, not convinced. may be useful, maybe not?sam
09/12/2020, 1:09 PMmitch
09/12/2020, 10:01 PMsam
09/12/2020, 10:02 PMmitch
09/18/2020, 10:09 PMmitch
09/25/2020, 11:46 PMsam
09/25/2020, 11:46 PMsam
09/25/2020, 11:47 PMmitch
09/25/2020, 11:47 PMmitch
09/25/2020, 11:47 PMmitch
09/25/2020, 11:47 PMsam
09/25/2020, 11:47 PMmitch
09/25/2020, 11:47 PMmitch
09/25/2020, 11:54 PMsam
09/25/2020, 11:54 PMmitch
09/26/2020, 12:12 AMsam
09/26/2020, 12:18 AMmitch
09/26/2020, 12:20 AMmitch
09/26/2020, 12:27 AMfun <T> Arb<T>.toExhaustive(rs: RandomSource, distinct: boolean = false): Exhaustive<T>
makes more sensesam
09/26/2020, 12:27 AMmitch
09/26/2020, 12:28 AMsam
09/26/2020, 12:28 AMsam
09/26/2020, 12:28 AMsam
09/26/2020, 12:28 AMsam
09/26/2020, 12:28 AMmitch
09/26/2020, 12:30 AMsam
09/26/2020, 12:31 AMmitch
09/26/2020, 12:31 AMsam
09/26/2020, 12:32 AMmitch
09/26/2020, 12:32 AMmitch
09/26/2020, 12:34 AMEdgeCases<A>
that’s gonna solve that problem, but it’s a bit of a big onesam
09/26/2020, 12:34 AMmitch
09/26/2020, 12:35 AMmitch
09/26/2020, 12:35 AMsam
09/26/2020, 12:35 AMmitch
09/26/2020, 12:36 AMsam
09/26/2020, 12:36 AMmitch
09/26/2020, 12:36 AMwithEdgecsases
aready, i don’t think it really matters that muchsam
09/26/2020, 12:37 AMsam
09/26/2020, 12:37 AMmitch
09/26/2020, 12:38 AM/**
* Returns a new [Arb] which takes its elements from the receiver and maps them using the supplied function.
*/
fun <A, B> Arb<A>.flatMap(f: (A) -> Arb<B>): Arb<B> = object : Arb<B>() {
override fun edgecases(): List<B> = this@flatMap.edgecases().flatMap { f(it).edgecases() }
override fun sample(rs: RandomSource): Sample<B> = f(this@flatMap.sample(rs).value).sample(rs)
}
sam
09/26/2020, 12:39 AM