From ba37ac94537fa5c70b13686e4853380183358240 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Thu, 14 Jul 2022 13:24:59 +0200 Subject: [PATCH] remove dependency on FastTransforms (#33) * remove dependency on FastTransforms * fix typo in comments * be explicit about imports from SpecialFunctions * extra project for tests * CompatHelper for tests * add LinearAlgebra to test dependencies * use FastGaussQuadrature via PolynomialBases in tests * fix Path to conda environment is not valid --- .github/workflows/CompatHelper.yml | 2 +- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ .gitignore | 9 +++++---- Project.toml | 14 ++------------ src/PolynomialBases.jl | 8 ++++---- src/nodal_bases.jl | 17 +++++++++++++++-- test/Project.toml | 12 ++++++++++++ test/gegenbauer_test.jl | 2 +- test/hahn_test.jl | 2 +- test/hermite_test.jl | 2 +- test/jacobi_test.jl | 4 ++-- test/laguerre_test.jl | 2 +- test/legendre_test.jl | 4 ++-- test/sympy_test.jl | 2 +- 14 files changed, 70 insertions(+), 32 deletions(-) create mode 100644 test/Project.toml diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index a67914a..d298b85 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -13,4 +13,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} # optional - run: julia -e 'using CompatHelper; CompatHelper.main()' + run: julia -e 'using CompatHelper; CompatHelper.main(; subdirs=["", "test"])' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0281f10..7a81b83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,28 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 env: PYTHON: "" + - name: Fix weird Conda.jl/PyCall.jl/SymPy.jl build error + env: + PYTHON: "" + shell: julia --color=yes {0} + run: | + using Pkg + Pkg.activate("test") + println("Try instantiating the test environment") + try + Pkg.instantiate() + println("Successfully instantiated the test environment") + catch e + display(e) + end + println("Try building SymPy") + try + Pkg.build("SymPy") + import SymPy + println("Successfully built SymPy") + catch e + display(e) + end - uses: julia-actions/julia-runtest@v1 env: PYTHON: "" diff --git a/.gitignore b/.gitignore index 355f04f..9bb63c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -*.jl.cov -*.jl.*.cov -*.jl.mem -notebooks/.ipynb_checkpoints/ +**/*.jl.cov +**/*.jl.*.cov +**/*.jl.mem +**/.ipynb_checkpoints/ +**/Manifest.toml diff --git a/Project.toml b/Project.toml index 7822292..51dc9cd 100644 --- a/Project.toml +++ b/Project.toml @@ -5,8 +5,8 @@ version = "0.4.13-pre" [deps] ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197" +FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838" -FastTransforms = "057dd010-8810-581a-b7be-e3fc3b93f78c" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Requires = "ae029012-a4dd-5104-9daa-d747884805df" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" @@ -14,19 +14,9 @@ UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" [compat] ArgCheck = "2.0" +FFTW = "1" FastGaussQuadrature = "0.4.2" -FastTransforms = "0.11, 0.12, 0.13, 0.14" Requires = "1" SpecialFunctions = "1, 2" UnPack = "1" julia = "1.6" - -[extras] -InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" -StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" -SymEngine = "123dc426-2d89-5057-bbad-38513e3affd8" -SymPy = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["InteractiveUtils", "StaticArrays", "SymEngine", "SymPy", "Test"] diff --git a/src/PolynomialBases.jl b/src/PolynomialBases.jl index 1ed4bf2..a088041 100644 --- a/src/PolynomialBases.jl +++ b/src/PolynomialBases.jl @@ -2,12 +2,12 @@ module PolynomialBases using LinearAlgebra -using ArgCheck -using FastGaussQuadrature: gausslegendre, gausslobatto, gaussjacobi -using FastTransforms: clenshawcurtisnodes, clenshawcurtisweights, chebyshevmoments1 +using ArgCheck: @argcheck +using FFTW: FFTW +using FastGaussQuadrature: FastGaussQuadrature, gausslegendre, gausslobatto, gaussjacobi using Requires: @require using UnPack: @unpack -using SpecialFunctions +using SpecialFunctions: gamma # types diff --git a/src/nodal_bases.jl b/src/nodal_bases.jl index beb2c6b..0d57606 100644 --- a/src/nodal_bases.jl +++ b/src/nodal_bases.jl @@ -383,8 +383,21 @@ function ClenshawCurtis(p::Int, T=Float64) nodes = T[0] weights = T[2] else - nodes = clenshawcurtisnodes(T, p+1) |> collect - weights = clenshawcurtisweights(chebyshevmoments1(T, p+1)) + nodes = Vector{T}(undef, p + 1) + for k in eachindex(nodes) + nodes[k] = sinpi(convert(T, p + 2 - 2 * k) / (2 * p)) + end + + weights = zeros(T, p + 1) + for i in 0:2:p + @inbounds weights[i+1] = convert(T, 2) / convert(T, (1 - i^2)) + end + rmul!(weights, inv(convert(T, p))) + plan = FFTW.plan_r2r!(weights, FFTW.REDFT00) + plan * weights + half = inv(convert(T, 2)) + weights[1] *= half + weights[end] *= half end baryweights = barycentric_weights(nodes) D = derivative_matrix(nodes, baryweights) diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 0000000..30daac5 --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,12 @@ +[deps] +InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +SymEngine = "123dc426-2d89-5057-bbad-38513e3affd8" +SymPy = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +StaticArrays = "1" +SymEngine = "0.8" +SymPy = "1" diff --git a/test/gegenbauer_test.jl b/test/gegenbauer_test.jl index 2a2791d..655cf23 100644 --- a/test/gegenbauer_test.jl +++ b/test/gegenbauer_test.jl @@ -1,6 +1,6 @@ using Test, PolynomialBases -if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not install on https://github.com/JuliaComputing/NewPkgEval.jl +if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not installed on https://github.com/JuliaComputing/NewPkgEval.jl import SymPy x, α = SymPy.symbols("x, alpha") diff --git a/test/hahn_test.jl b/test/hahn_test.jl index 196ecd2..3f2bb50 100644 --- a/test/hahn_test.jl +++ b/test/hahn_test.jl @@ -1,6 +1,6 @@ using Test, PolynomialBases -if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not install on https://github.com/JuliaComputing/NewPkgEval.jl +if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not installed on https://github.com/JuliaComputing/NewPkgEval.jl import SymPy x, α, β, N = SymPy.symbols("x, alpha, beta, N") diff --git a/test/hermite_test.jl b/test/hermite_test.jl index 1f6faed..f208ad7 100644 --- a/test/hermite_test.jl +++ b/test/hermite_test.jl @@ -1,6 +1,6 @@ using Test, PolynomialBases -if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not install on https://github.com/JuliaComputing/NewPkgEval.jl +if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not installed on https://github.com/JuliaComputing/NewPkgEval.jl import SymPy x = SymPy.symbols("x") diff --git a/test/jacobi_test.jl b/test/jacobi_test.jl index 685549e..7c06892 100644 --- a/test/jacobi_test.jl +++ b/test/jacobi_test.jl @@ -1,6 +1,6 @@ -using Test, PolynomialBases, FastGaussQuadrature +using Test, PolynomialBases, PolynomialBases.FastGaussQuadrature -if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not install on https://github.com/JuliaComputing/NewPkgEval.jl +if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not installed on https://github.com/JuliaComputing/NewPkgEval.jl import SymPy x, α, β = SymPy.symbols("x, alpha, beta") diff --git a/test/laguerre_test.jl b/test/laguerre_test.jl index 933fc6b..fac584d 100644 --- a/test/laguerre_test.jl +++ b/test/laguerre_test.jl @@ -1,6 +1,6 @@ using Test, PolynomialBases -if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not install on https://github.com/JuliaComputing/NewPkgEval.jl +if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not installed on https://github.com/JuliaComputing/NewPkgEval.jl import SymPy x, α = SymPy.symbols("x, alpha") diff --git a/test/legendre_test.jl b/test/legendre_test.jl index 8626ff8..c9efb6e 100644 --- a/test/legendre_test.jl +++ b/test/legendre_test.jl @@ -1,6 +1,6 @@ -using Test, PolynomialBases, FastGaussQuadrature +using Test, PolynomialBases, PolynomialBases.FastGaussQuadrature -if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not install on https://github.com/JuliaComputing/NewPkgEval.jl +if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not installed on https://github.com/JuliaComputing/NewPkgEval.jl import SymPy x = SymPy.symbols("x") diff --git a/test/sympy_test.jl b/test/sympy_test.jl index d98cda7..85abdfb 100644 --- a/test/sympy_test.jl +++ b/test/sympy_test.jl @@ -1,6 +1,6 @@ using Test, PolynomialBases -if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not install on https://github.com/JuliaComputing/NewPkgEval.jl +if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not installed on https://github.com/JuliaComputing/NewPkgEval.jl import SymPy tol = 5.e-15