Uh oh!
There was an error while loading. Please reload this page.
array generation: allow specifying dims as distributions - #10
Conversation
The number of dimensions is still fixed, but the sizes can be
computed at runtime, when specified as a distributions.
For example `rand(make(Vector, Int, 1:3))` creates a `Vector{Int}`
of random length in `1:3`.rfourquet
commented
Mar 21, 2020
The motivation for this change is to derive (probably in a separate package) a distribution for testing purposes (à la QuichCheck), where we want to test arrays with different sizes. The API could look like: for _=1:100@testmyfunction(rand(test(Matrix{Int})))
endWhere Of course, this is the first step, the same would follow for other containers. |
rfourquet
commented
Mar 21, 2020
@mschauer Maybe you have an opinion on this feature? |
mschauer
commented
Mar 23, 2020
I am not sure. I can see that a random matrix might have random size, but I would expect that a typical situation would sample the elements of the matrix conditional on the matrix sizes. |
rfourquet
commented
Mar 23, 2020
Thanks for your input!
Ok, I think I see what you mean, and if so then this would have to be implemented at another level. The current design is that each generation of "scalar" doesn't know the context, in particular doesn't know the dimensions of the array. The array as a whole would need to be considered as the unit of generation, probably similar as for I agree that random dimensions seems like a very marginal need, but I precisely had this need so I believe it's a good idea to enable that as an experimental feature, as it doesn't seem to be in the way of other features. |
The number of dimensions is still fixed, but the sizes can be
computed at runtime, when specified as a distributions.
For example
rand(make(Vector, Int, 1:3))creates aVector{Int}of random length in
1:3.