Skip to content

Commit

Permalink
try github actions for CI (#298)
Browse files Browse the repository at this point in the history
* try github actions for CI
* fix doctests
  • Loading branch information
jverzani authored Dec 2, 2020
1 parent fa05447 commit 99b3da1
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 74 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: CI
on:
pull_request:
branches:
- master
push:
branches:
- master
tags: '*'
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.0' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
- 'nightly'
os:
- ubuntu-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: |
julia --project=docs -e '
using Documenter: doctest
using Polynomials
doctest(Polynomials)'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "Polynomials"
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
license = "MIT"
author = "JuliaMath"
version = "1.1.12"
version = "1.1.13"

[deps]
GenericLinearAlgebra = "14197337-ba66-59df-a3e3-ca00e7dcff7a"
Expand Down
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Expand Down
1 change: 1 addition & 0 deletions src/pade.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Evaluate the Pade approximant at the given point.
julia> using Polynomials, Polynomials.PolyCompat, SpecialFunctions
julia> p = Polynomial(@.(1 // BigInt(gamma(1:17))));
Expand Down
27 changes: 18 additions & 9 deletions src/polynomials/LaurentPolynomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Laurent polynomials and standard basis polynomials promote to Laurent polynomi
Integration will fail if there is a `x⁻¹` term in the polynomial.
Example:
```jldoctest
```jldoctest laurent
julia> using Polynomials
julia> P = LaurentPolynomial
Expand Down Expand Up @@ -74,7 +74,7 @@ struct LaurentPolynomial{T <: Number} <: StandardBasisPolynomial{T}
m::Int,
var::Symbol=:x) where {T <: Number}


# trim zeros from front and back
lnz = findlast(!iszero, coeffs)
fnz = findfirst(!iszero, coeffs)
Expand Down Expand Up @@ -184,7 +184,7 @@ Base.:(==)(p1::LaurentPolynomial, p2::LaurentPolynomial) =
check_same_variable(p1, p2) && (degreerange(p1) == degreerange(p2)) && (coeffs(p1) == coeffs(p2))
Base.hash(p::LaurentPolynomial, h::UInt) = hash(p.var, hash(degreerange(p), hash(coeffs(p), h)))

isconstant(p::LaurentPolynomial) = iszero(lastindex(p)) && iszero(firstindex(p))
isconstant(p::LaurentPolynomial) = iszero(lastindex(p)) && iszero(firstindex(p))
basis(P::Type{<:LaurentPolynomial{T}}, n::Int, var::SymbolLike=:x) where{T} = LaurentPolynomial(ones(T,1), n, var)
basis(P::Type{LaurentPolynomial}, n::Int, var::SymbolLike=:x) = LaurentPolynomial(ones(Float64, 1), n, var)

Expand Down Expand Up @@ -307,12 +307,15 @@ end
This satisfies `conj(p(x)) = conj(p)(conj(x)) = p̄(conj(x))` or `p̄(x) = (conj ∘ p ∘ conj)(x)`
Examples
```jldoctest
```jldoctest laurent
julia> using Polynomials;
julia> z = variable(LaurentPolynomial, :z)
LaurentPolynomial(z)
julia> p = LaurentPolynomial([im, 1+im, 2 + im], -1:1, :z)
LaurentPolynomial(im*z⁻¹ + (1 + 1im) + (2 + 1im)*z)
julia> p = LaurentPolynomial([im, 1+im, 2 + im], -1, :z)
LaurentPolynomial(im*z⁻¹ + 1 + im + (2 + im)z)
julia> conj(p)(conj(z)) ≈ conj(p(z))
true
Expand All @@ -334,7 +337,9 @@ Call `p̂ = paraconj(p)` and `p̄` = conj(p)`, then this satisfies
Examples:
```jldoctest
```jldoctest laurent
julia> using Polynomials;
julia> z = variable(LaurentPolynomial, :z)
LaurentPolynomial(z)
Expand Down Expand Up @@ -372,11 +377,13 @@ This satisfies for *imaginary* `s`: `conj(p(s)) = p̃(s) = (conj ∘ p)(s) = cco
[ref](https://github.com/hurak/PolynomialEquations.jl#symmetrix-conjugate-equation-continuous-time-case)
Examples:
```jldoctest
```jldoctest laurent
julia> using Polynomials;
julia> s = 2im
0 + 2im
julia> p = LaurentPolynomial([im,-1, -im, 1], 1:2, :s)
julia> p = LaurentPolynomial([im,-1, -im, 1], 1, :s)
LaurentPolynomial(im*s - s² - im*s³ + s⁴)
julia> Polynomials.cconj(p)(s) ≈ conj(p(s))
Expand Down Expand Up @@ -508,6 +515,8 @@ The roots of a function (Laurent polynomial in this case) `a(z)` are the values
# Example
```julia
julia> using Polynomials;
julia> p = LaurentPolynomial([24,10,-15,0,1],-2:1,:z)
LaurentPolynomial(24*z⁻² + 10*z⁻¹ - 15 + z²)
Expand Down
34 changes: 17 additions & 17 deletions src/polynomials/multroot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ to identify roots of polynomials with suspected multiplicities over
Example:
```jldoctest
```
julia> using Polynomials
julia> p = fromroots([sqrt(2), sqrt(2), sqrt(2), 1, 1])
Expand All @@ -30,7 +30,7 @@ julia> roots(p)
1.4142350577588885 + 3.72273772278647e-5im
julia> Polynomials.Multroot.multroot(p)
(values = [0.9999999999999993, 1.4142135623730958], multiplicities = [2, 3], κ = 5.218455674370637, ϵ = 2.8736226244218195e-16)
(values = [0.9999999999999993, 1.4142135623730958], multiplicities = [2, 3], κ = 5.218455674370636, ϵ = 2.8736226244218195e-16)
```
The algorithm has two stages. First it uses `pejorative_manifold` to
Expand Down Expand Up @@ -60,7 +60,7 @@ multiplicity structure:
recursively, this allows the residual tolerance to scale up to match
increasing numeric errors.
Returns a named tuple with
Returns a named tuple with
* `values`: the identified roots
* `multiplicities`: the corresponding multiplicities
Expand All @@ -78,15 +78,15 @@ is misidentified.
"""
function multroot(p::Polynomials.StandardBasisPolynomial{T}; verbose=false,
kwargs...) where {T}

z, l = pejorative_manifold(p; kwargs...)
= pejorative_root(p, z, l)
κ, ϵ = stats(p, z̃, l)

verbose && show_stats(κ, ϵ)

(values = z̃, multiplicities = l, κ = κ, ϵ = ϵ)

end

# The multiplicity structure, `l`, gives rise to a pejorative manifold `Πₗ = {Gₗ(z) | z∈ Cᵐ}`.
Expand All @@ -99,11 +99,11 @@ function pejorative_manifold(p::Polynomials.StandardBasisPolynomial{T};
u, v, w, θ′, κ = Polynomials.ngcd(p, derivative(p),
atol=ρ*norm(p), satol = θ*norm(p),
rtol = zT, srtol = zT)

zs = roots(v)
nrts = length(zs)
ls = ones(Int, nrts)

while !Polynomials.isconstant(u)

normp = 1 + norm(u, 2)
Expand All @@ -127,7 +127,7 @@ function pejorative_manifold(p::Polynomials.StandardBasisPolynomial{T};
zs, ls # estimate for roots, multiplicities

end

"""
pejorative_root(p, zs, ls; kwargs...)
Expand Down Expand Up @@ -158,7 +158,7 @@ function pejorative_root(p, zs::Vector{S}, ls::Vector{Int};

# storage
a = p[2:end]./p[1] # a ~ (p[n-1], p[n-2], ..., p[0])/p[n]
W = Diagonal([min(1, 1/abs(aᵢ)) for aᵢ in a])
W = Diagonal([min(1, 1/abs(aᵢ)) for aᵢ in a])
J = zeros(S, m, n)
G = zeros(S, 1 + m)
Δₖ = zeros(S, n)
Expand All @@ -167,37 +167,37 @@ function pejorative_root(p, zs::Vector{S}, ls::Vector{Int};
cvg = false
δₖ₀ = -Inf
for ctr in 1:maxsteps

evalJ!(J, zₖs, ls)
evalG!(G, zₖs, ls)

Δₖ .= (W*J) \ (W*(view(G, 2:1+m) .- a)) # weighted least squares

δₖ₁ = norm(Δₖ, 2)
Δ = δₖ₀ - δₖ₁

if ctr > 10 && δₖ₁ >= δₖ₀
if ctr > 10 && δₖ₁ >= δₖ₀
δₖ₀ < δₖ₁ && @warn "Increasing Δ, terminating search"
cvg = true
break
end

zₖs .-= Δₖ

if δₖ₁^2 <= (δₖ₀ - δₖ₁) * τ
if δₖ₁^2 <= (δₖ₀ - δₖ₁) * τ
cvg = true
break
end

δₖ₀ = δₖ₁
end
verbose && show_stats(stats(p, zₖs, ls)...)

if cvg
return zₖs
else
@info ("""
The multiplicity count may be in error: the initial guess for the roots failed
The multiplicity count may be in error: the initial guess for the roots failed
to converge to a pejorative root.
""")
return(zₘs)
Expand Down Expand Up @@ -242,7 +242,7 @@ function evalJ!(J, zs::Vector{T}, ls::Vector) where {T}
for (k, zₖ) in enumerate(zs)
k == j && continue
for i in n-1:-1:1
J[1+i,j] -= zₖ * J[i,j]
J[1+i,j] -= zₖ * J[i,j]
end
end
end
Expand Down

2 comments on commit 99b3da1

@jverzani
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/25712

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.13 -m "<description of version>" 99b3da1dffdefa69786d98dad4cdb1aad3cf9784
git push origin v1.1.13

Please sign in to comment.