Skip to content

Commit 7408ecf

Browse files
authored
0.7 Deprecations (#13)
* Update Julia version * Complex128 -> ComplexF64 * Fix deprecation warnings * Make 0.7 changes compatible to 0.6 * Don't allow travis failure on nightly * Require only 0.6 * Fix using Test * use Compat in tests * Compat.LinearAlgebra * Fix
1 parent cd398cd commit 7408ecf

File tree

11 files changed

+33
-24
lines changed

11 files changed

+33
-24
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ git:
1313

1414
## uncomment the following lines to allow failures on nightly julia
1515
## (tests will run but not make your overall status red)
16-
matrix:
17-
allow_failures:
18-
- julia: nightly
16+
# matrix:
17+
# allow_failures:
18+
# - julia: nightly
1919

2020
## uncomment and modify the following lines to manually install system packages
2121
#addons:

REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
julia 0.6
2+
Compat 0.70
23
MultivariatePolynomials 0.1.1

src/FixedPolynomials.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module FixedPolynomials
88
abstract type AbstractPolySystem{T} end
99
export AbstractPolySystem
1010

11+
using Compat
12+
1113
#import Base: gradient
1214

1315
include("poly.jl")

src/config.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function PolyConfig(g::Polynomial{T}, reduced_exponents::Matrix{UInt16}, big_loo
1919
exponents = g.exponents
2020
m, n = size(reduced_exponents)
2121

22-
reduced_exponents_delimiters = Vector{UInt16}(n)
22+
reduced_exponents_delimiters = Vector{UInt16}(undef, n)
2323
reduced_exponents_map = Vector{NTuple{2, UInt16}}()
2424
for j=1:n
2525
nindices = 0
@@ -33,7 +33,7 @@ function PolyConfig(g::Polynomial{T}, reduced_exponents::Matrix{UInt16}, big_loo
3333
end
3434

3535
# monomials_full = BitMatrix(exponents)
36-
monomials_delimiters = Vector{UInt16}(n)
36+
monomials_delimiters = Vector{UInt16}(undef, n)
3737
monomials = Vector{UInt16}()
3838
for j=1:n
3939
nindices = 0
@@ -46,10 +46,10 @@ function PolyConfig(g::Polynomial{T}, reduced_exponents::Matrix{UInt16}, big_loo
4646
monomials_delimiters[j] = nindices
4747
end
4848

49-
grad_monomials_delimiters = Vector{Vector{Tuple{Delimiter, Exponent}}}(m)
50-
grad_monomials = Vector{Vector{Index}}(m)
49+
grad_monomials_delimiters = Vector{Vector{Tuple{Delimiter, Exponent}}}(undef, m)
50+
grad_monomials = Vector{Vector{Index}}(undef, m)
5151
for varindex = 1:m
52-
imonomials_delimiters = Vector{Tuple{Delimiter, Exponent}}(n)
52+
imonomials_delimiters = Vector{Tuple{Delimiter, Exponent}}(undef, n)
5353
imonomials = Vector{Index}()
5454
for j=1:n
5555
nindices = 0
@@ -369,7 +369,7 @@ mutable struct GradientDiffResult{T, AV<:AbstractVector{T}}
369369
end
370370

371371
function GradientDiffResult(cfg::GradientConfig{T}) where T
372-
GradientDiffResult{T, Vector{T}}(zero(T), Vector{T}(size(cfg.differences, 1)))
372+
GradientDiffResult{T, Vector{T}}(zero(T), Vector{T}(undef, size(cfg.differences, 1)))
373373
end
374374
function GradientDiffResult(grad::AbstractVector{T}) where T
375375
GradientDiffResult{T, Vector{T}}(zero(T), grad)

src/poly.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ function _coefficients_exponents(poly::MP.AbstractPolynomialLike{T}, vars) where
6464
terms = MP.terms(poly)
6565
nterms = length(terms)
6666
nvars = length(vars)
67-
exps = Matrix{Int}(nvars, nterms)
68-
coefficients = Vector{T}(nterms)
67+
exps = Matrix{Int}(undef, nvars, nterms)
68+
coefficients = Vector{T}(undef, nterms)
6969
for j = 1:nterms
7070
term = terms[j]
7171
coefficients[j] = MP.coefficient(term)
@@ -244,7 +244,7 @@ function substitute(p::Polynomial{S}, varindex, x::T) where {S<:Number, T<:Numbe
244244

245245
for j = 1:nterms
246246
coeff = cfs[j]
247-
exp = Vector{Int}(nvars - 1)
247+
exp = Vector{Int}(undef, nvars - 1)
248248
# first we calculate the new coefficient and remove the varindex-th row
249249
for i = 1:nvars
250250
if i == varindex
@@ -339,7 +339,7 @@ Checks whether `p` is a homogenous polynomial. Note that this is unaffected from
339339
value of `homogenized(p)`.
340340
"""
341341
function ishomogenous(p::Polynomial)
342-
monomials_degree = sum(exponents(p), 1)
342+
monomials_degree = Compat.sum(exponents(p), dims=1)
343343
max_deg = monomials_degree[1]
344344
all(x -> x == max_deg, monomials_degree)
345345
end
@@ -354,7 +354,7 @@ function homogenize(p::Polynomial, variable::Symbol=:x0; respect_homogenous=true
354354
if p.homogenized || (respect_homogenous && ishomogenous(p))
355355
p
356356
else
357-
monomials_degree = sum(exponents(p), 1)
357+
monomials_degree = Compat.sum(exponents(p), dims=1)
358358
max_deg = monomials_degree[1]
359359
Polynomial([max_deg .- monomials_degree; exponents(p)], coefficients(p), [variable; variables(p)], true)
360360
end

src/system.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,12 @@ function JacobianDiffResult(cfg::JacobianConfig{T}) where T
245245
zeros(T, length(cfg.polys), size(cfg.differences, 1)))
246246
end
247247

248-
function JacobianDiffResult(value::AbstractVector{T}, jacobian::AbstractMatrix{T}) where T
249-
JacobianDiffResult{T, typeof(value), typeof(jacobian)}(value, jacobian)
248+
@static if VERSION < v"0.7-"
249+
function JacobianDiffResult(value::AbstractVector{T}, jacobian::AbstractMatrix{T}) where T
250+
JacobianDiffResult{T, typeof(value), typeof(jacobian)}(value, jacobian)
251+
end
250252
end
253+
251254
value(r::JacobianDiffResult) = r.value
252255
jacobian(r::JacobianDiffResult) = r.jacobian
253256

src/tables.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function computetables(exponents::Matrix{T}) where {T<:Integer}
2424
end
2525
# now we copy the relevant subsection
2626
# we do not compute the differences now since we need to compute the lookuptable first
27-
differences = Matrix{UInt8}(m, maxk)
27+
differences = Matrix{UInt8}(undef, m, maxk)
2828
for i=1:m, j=1:maxk
2929
differences[i, j] = lookuptable[j, i]
3030
end

test/config_test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
@test_throws BoundsError FixedPolynomials.gradient!(u, f, rand(2), cfg)
2222
@test_throws BoundsError FixedPolynomials.gradient!(u[1:2], f, w, cfg)
2323

24-
wc = rand(Complex128, 3)
25-
uc = zeros(Complex128, 3)
24+
wc = rand(ComplexF64, 3)
25+
uc = zeros(ComplexF64, 3)
2626
cfg = config(f, wc)
2727
@test cfg isa GradientConfig
2828
@test f(wc) evaluate(f, wc, cfg)

test/poly_test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@test variables(p) == [:x1, :x2, :x3]
1212
@test degree(p) == 4
1313

14-
@test (convert(Polynomial{Complex128}, p) isa Polynomial{Complex128})
14+
@test (convert(Polynomial{ComplexF64}, p) isa Polynomial{ComplexF64})
1515
q = Polynomial([3 1; 1 1; 0 2], [-2, 3], [:x_1, :x_2, :x_3])
1616
prom_p, prom_q = promote(p,q)
1717
@test typeof(prom_p) == typeof(prom_q)
@@ -88,7 +88,7 @@
8888
# Due to bug during evaluation of "empty" polynomials
8989
F = convert(Vector{Polynomial{Float64}}, [f, g, h])
9090

91-
J = [differentiate(f, i) for f in F, i=1:nvariables.(F[1])]
91+
J = [differentiate(f, i) for f in F, i=1:nvariables(F[1])]
9292
u = rand(3)
9393
@test map(f -> evaluate(f, u), J) == [1.0 1.0 2.0; 1.0 0.0 1.0; 0.0 1.0 1.0]
9494
end

test/runtests.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using FixedPolynomials
2-
using Base.Test
2+
using Compat.Test
3+
using Compat
34

45
import DynamicPolynomials
5-
Impl = DynamicPolynomials
6+
const Impl = DynamicPolynomials
67
include("poly_test.jl")
78
include("config_test.jl")
89
include("system_test.jl")

0 commit comments

Comments
 (0)