Skip to content

Commit c3a5b88

Browse files
authored
Merge pull request #89 from JuliaAlgebra/0.7
Update package for 0.7 only
2 parents cd76ab8 + 7cdf115 commit c3a5b88

13 files changed

+51
-67
lines changed

.travis.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ language: julia
33
os:
44
- linux
55
julia:
6-
- 0.6
6+
- 0.7
7+
- 1.0
78
- nightly
9+
10+
matrix:
11+
allow_failures:
12+
- julia: nightly
13+
814
notifications:
915
email: false
16+
1017
after_success:
1118
# push coverage results to Coveralls
1219
- julia -e 'cd(Pkg.dir("MultivariatePolynomials")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'

REQUIRE

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
julia 0.6
2-
Compat 0.61
1+
julia 0.7

appveyor.yml

+14-21
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: latest
75

6+
platform:
7+
- x86 # 32-bit
8+
- x64 # 64-bit
9+
10+
## uncomment the following lines to allow failures on nightly julia
11+
## (tests will run but not make your overall status red)
812
matrix:
913
allow_failures:
10-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
11-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
14+
- julia_version: latest
1215

1316
branches:
1417
only:
@@ -22,22 +25,12 @@ notifications:
2225
on_build_status_changed: false
2326

2427
install:
25-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
26-
# Download most recent Julia Windows binary
27-
- ps: (new-object net.webclient).DownloadFile(
28-
$env:JULIA_URL,
29-
"C:\projects\julia-binary.exe")
30-
# Run installer silently, output to C:\projects\julia
31-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
28+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
3229

3330
build_script:
34-
# Need to convert from shallow to complete for Pkg.clone to work
35-
- IF EXIST .git\shallow (git fetch --unshallow)
36-
- C:\projects\julia\bin\julia -e "versioninfo();
37-
Pkg.clone(pwd(), \"MultivariatePolynomials\");
38-
Pkg.clone(\"https://github.com/blegat/DynamicPolynomials.jl\");
39-
Pkg.clone(\"https://github.com/rdeits/TypedPolynomials.jl\");
40-
Pkg.build(\"MultivariatePolynomials\")"
31+
- echo "%JL_BUILD_SCRIPT%"
32+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
4133

4234
test_script:
43-
- C:\projects\julia\bin\julia -e "Pkg.test(\"MultivariatePolynomials\")"
35+
- echo "%JL_TEST_SCRIPT%"
36+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

src/MultivariatePolynomials.jl

+1-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
1-
__precompile__()
2-
31
module MultivariatePolynomials
42

5-
#using DocStringExtensions
6-
7-
using Compat
8-
import Compat.LinearAlgebra
9-
10-
# The ' operator lowers to `transpose()` in v0.6 and to
11-
# `adjoint()` in v0.7+.
12-
# TOOD: remove this switch when dropping v0.6 support
13-
@static if VERSION <= v"0.7.0-DEV.3351"
14-
import Base: transpose
15-
const adjoint_operator = transpose
16-
else
17-
import Compat.LinearAlgebra: adjoint
18-
const adjoint_operator = adjoint
19-
end
3+
import LinearAlgebra
204

215
export AbstractPolynomialLike, AbstractTermLike, AbstractMonomialLike
226
"""

src/det.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
function Compat.LinearAlgebra.det(M::Matrix{<:AbstractPolynomialLike})
1+
function LinearAlgebra.det(M::Matrix{<:AbstractPolynomialLike})
22
m = size(M)[1]
33
if m > 2
4-
return sum((-1)^(i-1) * M[i,1] * det(M[1:end .!= i, 2:end]) for i in 1:m)
4+
return sum((-1)^(i-1) * M[i,1] * LinearAlgebra.det(M[1:end .!= i, 2:end]) for i in 1:m)
55
else
66
return M[1,1] * M[2,2] - M[2,1] * M[1,2]
77
end

src/differentiation.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ differentiate(p::ARPL, m::AbstractMonomial) = differentiate(p, variable(m))
6363
# so we just set `R` to `Any`
6464
function (_differentiate_recursive(p, x, deg::Int, ::Type{R})::R) where {R}
6565
if deg < 0
66-
throw(DomainError())
66+
throw(DomainError(deg, "degree is negative"))
6767
elseif deg == 0
6868
return p
6969
else

src/hash.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ function Base.hash(p::AbstractPolynomial, u::UInt)
3131
if iszero(p)
3232
hash(0, u)
3333
else
34-
reduce((u, t) -> hash(t, u), u, terms(p))
34+
reduce((u, t) -> hash(t, u), terms(p); init=u)
3535
end
3636
end

src/operators.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ for op in [:+, :-]
9999
end
100100
end
101101

102-
adjoint_operator(v::AbstractVariable) = v
103-
adjoint_operator(m::AbstractMonomial) = m
104-
adjoint_operator(t::T) where {T <: AbstractTerm} = adjoint_operator(coefficient(t)) * monomial(t)
105-
adjoint_operator(p::AbstractPolynomialLike) = polynomial(map(adjoint_operator, terms(p)))
106-
107-
Compat.LinearAlgebra.dot(p1::AbstractPolynomialLike, p2::AbstractPolynomialLike) = p1' * p2
108-
Compat.LinearAlgebra.dot(x, p::AbstractPolynomialLike) = x' * p
109-
Compat.LinearAlgebra.dot(p::AbstractPolynomialLike, x) = p' * x
102+
LinearAlgebra.adjoint(v::AbstractVariable) = v
103+
LinearAlgebra.adjoint(m::AbstractMonomial) = m
104+
LinearAlgebra.adjoint(t::T) where {T <: AbstractTerm} = LinearAlgebra.adjoint(coefficient(t)) * monomial(t)
105+
LinearAlgebra.adjoint(p::AbstractPolynomialLike) = polynomial(map(LinearAlgebra.adjoint, terms(p)))
106+
107+
LinearAlgebra.dot(p1::AbstractPolynomialLike, p2::AbstractPolynomialLike) = p1' * p2
108+
LinearAlgebra.dot(x, p::AbstractPolynomialLike) = x' * p
109+
LinearAlgebra.dot(p::AbstractPolynomialLike, x) = p' * x
110110

111111
# Amazingly, this works! Thanks, StaticArrays.jl!
112112
"""

src/polynomial.jl

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export mindegree, maxdegree, extdegree
44
export leadingterm, leadingcoefficient, leadingmonomial
55
export removeleadingterm, removemonomials, monic
66

7-
Compat.LinearAlgebra.norm(p::AbstractPolynomialLike, r::Int=2) = norm(coefficients(p), r)
7+
LinearAlgebra.norm(p::AbstractPolynomialLike, r::Int=2) = LinearAlgebra.norm(coefficients(p), r)
88

99
changecoefficienttype(::Type{TT}, ::Type{T}) where {TT<:AbstractTermLike, T} = termtype(TT, T)
1010
changecoefficienttype(::Type{PT}, ::Type{T}) where {PT<:AbstractPolynomial, T} = polynomialtype(PT, T)
@@ -54,7 +54,7 @@ polynomial(ts::AbstractVector{<:AbstractTerm}, s::SortedUniqState) = polynomial(
5454
polynomial(a::AbstractVector, x::AbstractVector, s::ListState=MessyState()) = polynomial([α * m for (α, m) in zip(a, x)], s)
5555
polynomial(f::Function, mv::AbstractVector{<:AbstractMonomialLike}) = polynomial([f(i) * mv[i] for i in 1:length(mv)])
5656
function polynomial(Q::AbstractMatrix, mv::AbstractVector)
57-
dot(mv, Q * mv)
57+
LinearAlgebra.dot(mv, Q * mv)
5858
end
5959
function polynomial(Q::AbstractMatrix, mv::AbstractVector, ::Type{T}) where T
6060
polynomial(polynomial(Q, mv), T)
@@ -368,8 +368,10 @@ function mapcoefficientsnz(f::Function, p::AbstractPolynomialLike)
368368
end
369369
mapcoefficientsnz(f::Function, t::AbstractTermLike) = f(coefficient(t)) * monomial(t)
370370

371-
Base.round(t::AbstractTermLike, args...) = round(coefficient(t), args...) * monomial(t)
372-
function Base.round(p::AbstractPolynomialLike, args...)
371+
Base.round(t::AbstractTermLike; args...) = round(coefficient(t); args...) * monomial(t)
372+
function Base.round(p::AbstractPolynomialLike; args...)
373373
# round(0.1) is zero so we cannot use SortedUniqState
374-
polynomial(round.(terms(p), args...), SortedState())
374+
polynomial(round.(terms(p); args...), SortedState())
375375
end
376+
377+
Base.broadcastable(p::AbstractPolynomialLike) = Ref(p)

test/REQUIRE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
BenchmarkTools
2-
TypedPolynomials
2+
DynamicPolynomials 0.1

test/polynomial.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ const MP = MultivariatePolynomials
118118

119119
@test (@inferred round(2.6x + 1.001x^2)) == 3x + 1x^2
120120
@test (@inferred round(3.1x*y)) == 3x*y
121-
@test (@inferred round(2.613x + 1.1051x^2, 2)) 2.61x + 1.11x^2
122-
@test (@inferred round(3.145x*y, 1)) 3.1x*y
121+
@test (@inferred round(2.613x + 1.1051x^2, digits=2)) 2.61x + 1.11x^2
122+
@test (@inferred round(3.145x*y, digits=1)) 3.1x*y
123123

124124
@testset "Graded Lex Order" begin
125125
Mod.@polyvar x y z

test/runtests.jl

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using Compat
2-
using Compat.Test
3-
using Compat.LinearAlgebra
1+
using Test
2+
using LinearAlgebra
43

54
using MultivariatePolynomials
65
const MP = MultivariatePolynomials

test/substitution.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Compat.Test: @inferred
1+
import Test: @inferred
22

33
@testset "Substitution" begin
44
Mod.@polyvar x[1:3]
@@ -12,10 +12,10 @@ using Compat.Test: @inferred
1212
@test (x[1])(x[1]=>x[2]) == x[2]
1313

1414
p = x[1]*x[2]*x[3]
15-
@test Int(p(x => (1, 2, 3))) == 6
15+
@test convert(Int, p(x => (1, 2, 3))) == 6
1616

1717
p = x[1]^2 + x[1]*x[3] - 3
18-
@test Int(p(x => (5, x[1]*x[2], 4))) == 42
18+
@test convert(Int, p(x => (5, x[1]*x[2], 4))) == 42
1919

2020
p = x[1]^2 + x[2]^2
2121
q = p(x[1:2] => [1 -1; 1 1] * vec(x[1:2]))

0 commit comments

Comments
 (0)