From 6c13046c037e570c9c4753f8395a1debc68e4a17 Mon Sep 17 00:00:00 2001 From: mauro-milella Date: Wed, 16 Oct 2024 19:41:59 +0200 Subject: [PATCH] randformula atompicker docstring enriched --- src/generation/docstrings.jl | 10 ++++++---- test/generation/formula.jl | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/generation/docstrings.jl b/src/generation/docstrings.jl index 0314486..8b58209 100644 --- a/src/generation/docstrings.jl +++ b/src/generation/docstrings.jl @@ -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. diff --git a/test/generation/formula.jl b/test/generation/formula.jl index 6e6a546..31fe3ca 100644 --- a/test/generation/formula.jl +++ b/test/generation/formula.jl @@ -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)