Skip to content

Commit 49a78ec

Browse files
authored
compat fixes for 0.7 (#214)
1 parent 8e2cd6a commit 49a78ec

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

src/HighLevelInterface/quadprog.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ function quadprog(c::InputVector, Q::AbstractMatrix, A::AbstractMatrix, rowlb::I
3434
rhs = rowubtmp
3535
@assert realtype <: Real
3636
warn_no_inf(realtype)
37-
rowlb = Array{realtype}(nrow)
38-
rowub = Array{realtype}(nrow)
37+
rowlb = Array{realtype}(undef, nrow)
38+
rowub = Array{realtype}(undef, nrow)
3939
for i in 1:nrow
4040
if sense[i] == '<'
4141
rowlb[i] = typemin(realtype)

src/SolverInterface/nonlinear_to_lpqp.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ function jac_structure(d::LPQPEvaluator)
188188
jac_nnz += 2*length(d.Qconstr[i].quadrowidx)
189189
end
190190

191-
I = Vector{Int}(jac_nnz)
192-
J = Vector{Int}(jac_nnz)
191+
I = Vector{Int}(undef, jac_nnz)
192+
J = Vector{Int}(undef, jac_nnz)
193193
idx = 1
194194
for col = 1:size(d.A,2)
195195
for pos = d.A.colptr[col]:(d.A.colptr[col+1]-1)
@@ -244,8 +244,8 @@ function hesslag_structure(d::LPQPEvaluator)
244244
hess_nnz += length(d.Qconstr[i].quadrowidx)
245245
end
246246

247-
I = Vector{Int}(hess_nnz)
248-
J = Vector{Int}(hess_nnz)
247+
I = Vector{Int}(undef, hess_nnz)
248+
J = Vector{Int}(undef, hess_nnz)
249249

250250
for k in 1:length(d.Qi)
251251
I[k] = d.Qi[k]

test/nlp.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Base.Test
22
using MathProgBase
3+
using Compat
34

45
# Here the type represents the complete instance, but it
56
# could also store instance data.
@@ -114,7 +115,7 @@ function nlptest(solver)
114115
MathProgBase.optimize!(m)
115116
stat = MathProgBase.status(m)
116117
@test stat == :Optimal
117-
if method_exists(MathProgBase.freemodel!, Tuple{typeof(m)})
118+
if hasmethod(MathProgBase.freemodel!, Tuple{typeof(m)})
118119
MathProgBase.freemodel!(m)
119120
end
120121
end
@@ -180,7 +181,7 @@ function nlptest_nohessian(solver)
180181
MathProgBase.optimize!(m)
181182
stat = MathProgBase.status(m)
182183
@test stat == :Optimal
183-
if method_exists(MathProgBase.freemodel!, Tuple{typeof(m)})
184+
if hasmethod(MathProgBase.freemodel!, Tuple{typeof(m)})
184185
MathProgBase.freemodel!(m)
185186
end
186187
end
@@ -262,7 +263,7 @@ function convexnlptest(solver)
262263
MathProgBase.optimize!(m)
263264
stat = MathProgBase.status(m)
264265
@test stat == :Optimal
265-
if method_exists(MathProgBase.freemodel!, Tuple{typeof(m)})
266+
if hasmethod(MathProgBase.freemodel!, Tuple{typeof(m)})
266267
MathProgBase.freemodel!(m)
267268
end
268269
end
@@ -333,7 +334,7 @@ function rosenbrocktest(solver)
333334
MathProgBase.optimize!(m)
334335
stat = MathProgBase.status(m)
335336
@test stat == :Optimal
336-
if method_exists(MathProgBase.freemodel!, Tuple{typeof(m)})
337+
if hasmethod(MathProgBase.freemodel!, Tuple{typeof(m)})
337338
MathProgBase.freemodel!(m)
338339
end
339340
end

test/quadprog.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function quadprogtest(solver)
1313
m = MathProgBase.LinearQuadraticModel(solver)
1414
MathProgBase.loadproblem!(m, [1. 2. 3.; 1. 1. 0.],[-Inf,-Inf,-Inf],[Inf,Inf,Inf],[0.,0.,0.],[4., 1.],[Inf,Inf], :Min)
1515

16-
MathProgBase.setquadobj!(m,diagm([10.0,10.0,10.0]))
16+
MathProgBase.setquadobj!(m,diagm(0 => [10.0,10.0,10.0]))
1717
rows = [1, 2, 2, 2, 3, 3, 3]
1818
cols = [1, 1, 1, 2, 2, 3, 3]
1919
vals = Float64[2, 0.5, 0.5, 2, 1, 1, 1]
@@ -44,7 +44,7 @@ function qpdualtest(solver)
4444
# s.t. x^2 <= 2
4545
@testset "QP1" begin
4646
m = MathProgBase.LinearQuadraticModel(solver)
47-
MathProgBase.loadproblem!(m, Array{Float64}(0,1), [-Inf], [Inf], [1.0], Float64[], Float64[], :Max)
47+
MathProgBase.loadproblem!(m, zeros(0,1), [-Inf], [Inf], [1.0], Float64[], Float64[], :Max)
4848
MathProgBase.addquadconstr!(m, [], [], [1], [1], [1.0], '<', 2.0)
4949
MathProgBase.optimize!(m)
5050
stat = MathProgBase.status(m)
@@ -62,7 +62,7 @@ function qpdualtest(solver)
6262
# s.t. x^2 <= 2
6363
@testset "QP2" begin
6464
m = MathProgBase.LinearQuadraticModel(solver)
65-
MathProgBase.loadproblem!(m, Array{Float64}(0,1), [-Inf], [Inf], [-1.0], Float64[], Float64[], :Min)
65+
MathProgBase.loadproblem!(m, zeros(0,1), [-Inf], [Inf], [-1.0], Float64[], Float64[], :Min)
6666
MathProgBase.addquadconstr!(m, [], [], [1], [1], [1.0], '<', 2.0)
6767
MathProgBase.optimize!(m)
6868
stat = MathProgBase.status(m)

0 commit comments

Comments
 (0)