Skip to content

Commit 2e7cdc8

Browse files
authored
Merge pull request #31 from JuliaAlgebra/0.7-only
Update to 0.7 (only)
2 parents 09bd791 + e08321a commit 2e7cdc8

File tree

11 files changed

+54
-51
lines changed

11 files changed

+54
-51
lines changed

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ os:
44
- linux
55
# - osx
66
julia:
7-
- 0.6
7+
- 0.7
88
- nightly
9+
10+
matrix:
11+
allow_failures:
12+
- julia: nightly
13+
914
notifications:
1015
email: false
1116

REQUIRE

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
julia 0.6
1+
julia 0.7
22
MultivariatePolynomials 0.1.3
3-
Nullables
4-
Compat 0.70

appveyor.yml

Lines changed: 14 additions & 18 deletions
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,19 +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(), \"DynamicPolynomials\"); Pkg.build(\"DynamicPolynomials\")"
31+
- echo "%JL_BUILD_SCRIPT%"
32+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
3833

3934
test_script:
40-
- C:\projects\julia\bin\julia -e "Pkg.test(\"DynamicPolynomials\")"
35+
- echo "%JL_TEST_SCRIPT%"
36+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

src/DynamicPolynomials.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
__precompile__()
2-
31
module DynamicPolynomials
42

5-
using Compat
6-
73
using MultivariatePolynomials
84
const MP = MultivariatePolynomials
95

10-
using Nullables
11-
126
# Exports which should be available for an enduser
137
import MultivariatePolynomials: differentiate, variables, subs, maxdegree, mindegree
148
export differentiate, variables, subs, maxdegree, mindegree

src/mono.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ end
3434
Monomial::Number) = Monomial{true}(α)
3535
end
3636

37+
Base.broadcastable(m::Monomial) = Ref(m)
3738
Base.copy(m::M) where {M<:Monomial} = M(m.vars, copy(m.z))
3839

3940
# Generate canonical reperesentation by removing variables that are not used

src/monovec.jl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ Base.endof(x::MonomialVector) = length(x)
4949
Base.size(x::MonomialVector) = (length(x),)
5050
Base.length(x::MonomialVector) = length(x.Z)
5151
Base.isempty(x::MonomialVector) = length(x) == 0
52-
Base.start(::MonomialVector) = 1
53-
Base.done(x::MonomialVector, state) = length(x) < state
54-
Base.next(x::MonomialVector, state) = (x[state], state+1)
52+
Base.iterate(x::MonomialVector) = isempty(x) ? nothing : (x[1], 1)
53+
function Base.iterate(x::MonomialVector, state::Int)
54+
state < length(x) ? (x[state+1], state+1) : nothing
55+
end
5556

5657
MultivariatePolynomials.extdegree(x::MonomialVector) = isempty(x) ? (0, 0) : extrema(sum.(x.Z))
5758
MultivariatePolynomials.mindegree(x::MonomialVector) = isempty(x) ? 0 : minimum(sum.(x.Z))
@@ -218,19 +219,21 @@ function MP.mergemonovec(ms::Vector{MonomialVector{C}}) where {C}
218219
L = length.(ms)
219220
X = Vector{Monomial{C}}()
220221
while any(I .<= L)
221-
max = Nullable{Monomial{C}}()
222+
max = nothing
222223
for i in 1:m
223224
if I[i] <= L[i]
224225
x = ms[i][I[i]]
225-
if isnull(max) || get(max) < x
226-
max = Nullable(x)
226+
if max === nothing || max < x
227+
max = x
227228
end
228229
end
229230
end
230-
@assert !isnull(max)
231-
push!(X, get(max))
231+
@assert max !== nothing
232+
# to ensure that max is no more a union
233+
max === nothing && return X
234+
push!(X, max)
232235
for i in 1:m
233-
if I[i] <= L[i] && get(max) == ms[i][I[i]]
236+
if I[i] <= L[i] && max == ms[i][I[i]]
234237
I[i] += 1
235238
end
236239
end

src/poly.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ end
2929

3030
iscomm(::Type{Polynomial{C, T}}) where {C, T} = C
3131

32+
Base.broadcastable(p::Polynomial) = Ref(p)
3233
Base.copy(p::Polynomial{C, T}) where {C, T} = Polynomial{C, T}(copy(p.a), copy(p.x))
3334
Base.zero(::Type{Polynomial{C, T}}) where {C, T} = Polynomial(T[], MonomialVector{C}())
3435
Base.one(::Type{Polynomial{C, T}}) where {C, T} = Polynomial([one(T)], MonomialVector{C}(PolyVar{C}[], [Int[]]))
@@ -75,9 +76,10 @@ Polynomial{C}(f::Function, x) where {C} = Polynomial{C, Base.promote_op(f, Int)}
7576

7677
Base.length(p::Polynomial) = length(p.a)
7778
Base.isempty(p::Polynomial) = isempty(p.a)
78-
Base.start(::Polynomial) = 1
79-
Base.done(p::Polynomial, state) = length(p) < state
80-
Base.next(p::Polynomial, state) = (p[state], state+1)
79+
Base.iterate(p::Polynomial) = isempty(p) ? nothing : (p[1], 1)
80+
function Base.iterate(p::Polynomial, state::Int)
81+
state < length(p) ? (p[state+1], state+1) : nothing
82+
end
8183
#eltype(::Type{Polynomial{C, T}}) where {C, T} = T
8284
Base.getindex(p::Polynomial, I::Int) = Term(p.a[I[1]], p.x[I[1]])
8385

@@ -90,9 +92,11 @@ Base.endof(p::TermIterator) = length(p.p)
9092
Base.length(p::TermIterator) = length(p.p.a)
9193
Base.size(p::TermIterator) = (length(p),)
9294
Base.isempty(p::TermIterator) = isempty(p.p.a)
93-
Base.start(::TermIterator) = 1
94-
Base.done(p::TermIterator, state) = length(p.p) < state
95-
Base.next(p::TermIterator, state) = (p.p[state], state+1)
95+
Base.iterate(p::TermIterator) = isempty(p) ? nothing : (p[1], 1)
96+
function Base.iterate(p::TermIterator, state::Int)
97+
state < length(p) ? (p[state+1], state+1) : nothing
98+
end
99+
96100
Base.getindex(p::TermIterator, I::Int) = Term(p.p.a[I[1]], p.p.x[I[1]])
97101

98102
MP.terms(p::Polynomial) = TermIterator(p)

src/term.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Term(x::PolyVar{C}) where C = Term{C}(x)
2222
Term{C, T}(α) where {C, T} = Term{C}(T(α))
2323
Term{C}::T) where {C, T} = Term{C, T}(α, Monomial{C}())
2424

25+
Base.broadcastable(t::Term) = Ref(t)
2526
#(::Type{TermContainer{C}}){C}(x::PolyVar{C}) = Term(x)
2627
#(::Type{TermContainer{C}}){C}(x::Monomial{C}) = Term(x)
2728
#(::Type{TermContainer{C}}){C}(t::TermContainer{C}) = t

src/var.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ end
3131

3232
# Variable vector x returned garanteed to be sorted so that if p is built with x then vars(p) == x
3333
macro polyvar(args...)
34-
Compat.reduce((x,y) -> :($x; $y), [buildpolyvar(PolyVar{true}, arg) for arg in args], init=:())
34+
reduce((x,y) -> :($x; $y), [buildpolyvar(PolyVar{true}, arg) for arg in args], init=:())
3535
end
3636
macro ncpolyvar(args...)
37-
Compat.reduce((x,y) -> :($x; $y), [buildpolyvar(PolyVar{false}, arg) for arg in args], init=:())
37+
reduce((x,y) -> :($x; $y), [buildpolyvar(PolyVar{false}, arg) for arg in args], init=:())
3838
end
3939

4040
struct PolyVar{C} <: AbstractVariable
@@ -49,6 +49,7 @@ struct PolyVar{C} <: AbstractVariable
4949
end
5050

5151
Base.hash(x::PolyVar, u::UInt) = hash(x.id, u)
52+
Base.broadcastable(x::PolyVar) = Ref(x)
5253

5354
MP.name(v::PolyVar) = v.name
5455
MP.monomial(v::PolyVar) = Monomial(v)

test/mvp.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using Compat.Pkg
2-
const mvp_test = joinpath(Pkg.dir("MultivariatePolynomials"), "test")
1+
using Pkg
2+
import MultivariatePolynomials
3+
const mvp_test = joinpath(dirname(pathof(MultivariatePolynomials)), "..", "test")
34
const Mod = DynamicPolynomials
45
const MP = MultivariatePolynomials
56
include(joinpath(mvp_test, "utils.jl"))

0 commit comments

Comments
 (0)