Skip to content

Commit

Permalink
Fixing some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dannys4 committed May 15, 2024
2 parents e212ab3 + 6bf86c4 commit 45b7735
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/MParT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,12 @@ All possible keyword arguments are in example, with some important arguments des
# Example
```jldoctest

Check failure on line 136 in src/MParT.jl

View workflow job for this annotation

GitHub Actions / Documentation

doctest failure in ~/work/MParT.jl/MParT.jl/src/MParT.jl:136-153 ```jldoctest julia> MapOptions(basisType="HermiteFunctions", basisLB=-3., basisUB=3., sigmoidBasisSumType="Constant") basisType = HermiteFunctions basisLB = -3 basisUB = 3 edgeType = SoftPlus sigmoidBasisSumType = Constant basisNorm = true posFuncType = SoftPlus quadType = AdaptiveSimpson quadAbsTol = 1e-06 quadRelTol = 1e-06 quadMaxSub = 30 quadMinSub = 0 quadPts = 5 contDeriv = true nugget = 0 ``` Subexpression: MapOptions(basisType="HermiteFunctions", basisLB=-3., basisUB=3., sigmoidBasisSumType="Constant") Evaluated output: ERROR: UndefVarError: `__Constant` not defined Stacktrace: [1] top-level scope @ :0 [2] eval @ ./boot.jl:370 [inlined] [3] eval @ ~/work/MParT.jl/MParT.jl/src/MParT.jl:2 [inlined] [4] MapOptions(; kwargs::Base.Pairs{Symbol, Any, NTuple{4, Symbol}, NamedTuple{(:basisType, :basisLB, :basisUB, :sigmoidBasisSumType), Tuple{String, Float64, Float64, String}}}) @ MParT ~/work/MParT.jl/MParT.jl/src/MParT.jl:163 [5] top-level scope @ none:1 Expected output: basisType = HermiteFunctions basisLB = -3 basisUB = 3 edgeType = SoftPlus sigmoidBasisSumType = Constant basisNorm = true posFuncType = SoftPlus quadType = AdaptiveSimpson quadAbsTol = 1e-06 quadRelTol = 1e-06 quadMaxSub = 30 quadMinSub = 0 quadPts = 5 contDeriv = true nugget = 0 diff = Warning: Diff output requires color. basisType = HermiteFunctions basisLB = -3 basisUB = 3 edgeType = SoftPlus sigmoidBasisSumType = Constant basisNorm = true posFuncType = SoftPlus quadType = AdaptiveSimpson quadAbsTol = 1e-06 quadRelTol = 1e-06 quadMaxSub = 30 quadMinSub = 0 quadPts = 5 contDeriv = true nugget = 0ERROR: UndefVarError: `__Constant` not defined Stacktrace: [1] top-level scope @ :0 [2] eval @ ./boot.jl:370 [inlined] [3] eval @ ~/work/MParT.jl/MParT.jl/src/MParT.jl:2 [inlined] [4] MapOptions(; kwargs::Base.Pairs{Symbol, Any, NTuple{4, Symbol}, NamedTuple{(:basisType, :basisLB, :basisUB, :sigmoidBasisSumType), Tuple{String, Float64, Float64, String}}}) @ MParT ~/work/MParT.jl/MParT.jl/src/MParT.jl:163 [5] top-level scope @ none:1
julia> MapOptions(basisType="HermiteFunctions", basisLB=-3., basisUB=3.)
julia> MapOptions(basisType="HermiteFunctions", basisLB=-3., basisUB=3., sigmoidBasisSumType="Constant")
basisType = HermiteFunctions
basisLB = -3
basisUB = 3
edgeType = SoftPlus
sigmoidBasisSumType = Constant
basisNorm = true
posFuncType = SoftPlus
quadType = AdaptiveSimpson
Expand Down
8 changes: 5 additions & 3 deletions test/mapFactory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ end

function test_CreateSigmoidMaps()
input_dim = 6
num_sigmoid = 5
num_sigmoid = 4
sigmoid_terms = num_sigmoid+3
centers_len = 2+(num_sigmoid*(num_sigmoid+1)) ÷ 2
max_degree = 3
centers = zeros(centers_len)
Expand All @@ -89,15 +90,16 @@ function test_CreateSigmoidMaps()
end
opts = MapOptions(basisType="HermiteFunctions")
sig = CreateSigmoidComponent(input_dim, max_degree, centers, opts)
expected_num_coeffs = binomial(input_dim+max_degree, input_dim)
expected_num_coeffs = binomial(input_dim-1+max_degree, input_dim-1)*(sigmoid_terms+1)
@test numCoeffs(sig) == expected_num_coeffs
mset = FixedMultiIndexSet(input_dim, max_degree)
sig_mset = CreateSigmoidComponent(mset, centers, opts)
@test numCoeffs(sig_mset) == size(mset)
output_dim = input_dim
centers_total = reduce(hcat, centers for _ in 1:output_dim)
sig_trimap = CreateSigmoidTriangular(input_dim, output_dim, max_degree, centers_total, opts)
expected_num_coeffs = sum(binomial(d+max_degree, d) for d in 1:input_dim)
expected_num_coeffs_dim = d->(sigmoid_terms+1)*binomial(d-1+max_degree, d-1)
expected_num_coeffs = sum(expected_num_coeffs_dim.(1:output_dim))
@test numCoeffs(sig_trimap) == expected_num_coeffs
end

Expand Down

0 comments on commit 45b7735

Please sign in to comment.