From 4bd1d3ab51dba05a14cd6255fdf0b981d355ea31 Mon Sep 17 00:00:00 2001 From: frankwswang Date: Tue, 26 Oct 2021 02:17:38 -0400 Subject: [PATCH 1/3] Formatting. --- src/Basis.jl | 1 + src/Tools.jl | 11 ----------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Basis.jl b/src/Basis.jl index 7bb47d57..424a3a6e 100644 --- a/src/Basis.jl +++ b/src/Basis.jl @@ -471,6 +471,7 @@ function ijkIndex(b::FloatingGTBasisFuncs) end """ + centerOf(bf::FloatingGTBasisFuncs) -> Array{<:Real, 1} Return the center coordinate of the input `FloatingGTBasisFuncs`. diff --git a/src/Tools.jl b/src/Tools.jl index 51201e8b..2ee6529e 100644 --- a/src/Tools.jl +++ b/src/Tools.jl @@ -436,17 +436,6 @@ function flatten(c::Array) [(c2...)...] end -function flatten2(c::Array) - c2 = map( x->(x isa Tuple ? Any[i for i in x] : x), c ) - vcat(c2...) -end - -function flatten3(c::Array) - head = c[1] isa Union{Array, Tuple} - c2 = map( x->(x isa Tuple ? Any[i for i in x] : x), c ) - vcat(c2...) -end - function flatten(c::Tuple) c2 = map( x->(x isa Union{Array, Tuple} ? x : [x]), c ) ((c2...)...,) From 328a7a1476a8c1f0e07dc3952e453ad6e6f93ea0 Mon Sep 17 00:00:00 2001 From: frankwswang Date: Tue, 26 Oct 2021 02:30:29 -0400 Subject: [PATCH 2/3] Added tests. --- test/unit-tests/Overload-test.jl | 1 + test/unit-tests/Tools-test.jl | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/test/unit-tests/Overload-test.jl b/test/unit-tests/Overload-test.jl index ce90d5b7..11fbedf5 100644 --- a/test/unit-tests/Overload-test.jl +++ b/test/unit-tests/Overload-test.jl @@ -222,6 +222,7 @@ using Suppressor: @capture_out @test axes(pb1) == () @test getindex(gf1) == gf1[] == gf1[begin] == gf1[end] == (gf1.param |> collect) + @test getindex(bf1) == bf1[] == bf1[begin] == bf1[end] == (bf1.param |> collect) bfm11 = Quiqbox.BasisFuncMix([bf1, bf2, bf1]) @test getindex(bfm11) == bfm11[] == bfm11[begin] == bfm11[end] == [bf1.gauss[1], bf2.gauss...] diff --git a/test/unit-tests/Tools-test.jl b/test/unit-tests/Tools-test.jl index 13229e10..55bfbdcd 100644 --- a/test/unit-tests/Tools-test.jl +++ b/test/unit-tests/Tools-test.jl @@ -1,6 +1,6 @@ using Test using Quiqbox: tryIncluding, @compareLength, hasBoolRelation, markUnique, flatten, - alignSignedNum, symbolReplace, splitTerm, groupedSort, mapPermute + alignSignedNum, symbolReplace, splitTerm, groupedSort, mapPermute, Pf, itself using Quiqbox using Symbolics using Suppressor: @capture_out @@ -95,4 +95,16 @@ using Suppressor: @capture_out @test bl1 @test bl2 @test bl3 + + # struct Pf + @test Pf(-1.5, abs)(-2) == -3.0 + @test Pf(-1.0, Pf(-1.5, abs))(-2) == 3.0 + @test Pf(1.5, Val(:abs))(-2) == 3.0 + @test Pf(-1.0, Val(Pf{-1.5, :abs}))(-2) == 3.0 + @test typeof(Pf(-1.5, abs))(-2) == -3.0 + + @test Pf(-1.0, Pf(-1.5, itself))(-2) == -3.0 + @test Pf(1.5, Val(:itself))(-2) == -3.0 + @test Pf(-1.0, Val(Pf{-1.5, :itself}))(-2) == -3.0 + @test typeof(Pf(-1.5, itself))(-2) == 3.0 end \ No newline at end of file From d41ef6897dfe3c2561f492ea593f8b9b8dde2e18 Mon Sep 17 00:00:00 2001 From: frankwswang Date: Tue, 26 Oct 2021 02:48:40 -0400 Subject: [PATCH 3/3] Fixed the bug. --- test/unit-tests/Overload-test.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit-tests/Overload-test.jl b/test/unit-tests/Overload-test.jl index 11fbedf5..22ffa177 100644 --- a/test/unit-tests/Overload-test.jl +++ b/test/unit-tests/Overload-test.jl @@ -222,7 +222,7 @@ using Suppressor: @capture_out @test axes(pb1) == () @test getindex(gf1) == gf1[] == gf1[begin] == gf1[end] == (gf1.param |> collect) - @test getindex(bf1) == bf1[] == bf1[begin] == bf1[end] == (bf1.param |> collect) + @test getindex(bf1) == bf1[] == bf1[begin] == bf1[end] == (bf1.gauss |> collect) bfm11 = Quiqbox.BasisFuncMix([bf1, bf2, bf1]) @test getindex(bfm11) == bfm11[] == bfm11[begin] == bfm11[end] == [bf1.gauss[1], bf2.gauss...]