Skip to content

Commit

Permalink
randformula atompicker docstring enriched
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro-milella committed Oct 16, 2024
1 parent 6a40e91 commit 6c13046
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/generation/docstrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,12 @@ Return a pseudo-randomic [`SyntaxTree`](@ref).
# Keyword Arguments
- `modaldepth::Integer`: maximum modal depth;
- `atompicker::Function`: method used to pick a random element. For example, this could be
Base.rand or StatsBase.sample;
- `opweights::AbstractWeights`: operators are sampled with probabilities proportional to
this vector vector (see [`AbstractWeights`](@ref) of StatsBase package).
- `atompicker::Union{Nothing,Function,AbstractWeights,AbstractVector{<:Real}}`: method used
to pick a random element. For example, this could be Base.rand, StatsBase.sample or
an array of integers or an array of `StatsBase.AbstractWeights`;
- `opweights::Union{Nothing,AbstractWeights,AbstractVector{<:Real}}`: operators are sampled
with probabilities proportional to this vector (see [`AbstractWeights`](@ref) of
StatsBase package).
- `alphabet_sample_kwargs::AbstractVector`: pool of atoms to pull from if the given alphabet
is not finite.
Expand Down
2 changes: 2 additions & 0 deletions test/generation/formula.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ Base.promote_rule(::Type{<:BooleanTruth}, ::Type{<:MyTruth}) = Truth
@test_nowarn randformula(4, my_grammar)
@test_nowarn randformula(MersenneTwister(1), 4, my_grammar)
@test_nowarn randformula(4, my_alph, my_ops)
@test_throws ArgumentError randformula(4, my_alph, my_ops; atompicker=[1,2])

@test_nowarn randformula(MersenneTwister(1), 4, my_alph, my_ops; atompicker = 1:5)
@test_throws ArgumentError randformula(
MersenneTwister(1), 4, my_alph, my_ops; atompicker = 1:6)
Expand Down

0 comments on commit 6c13046

Please sign in to comment.