Skip to content

Commit f6cd3b6

Browse files
committed
Avoid deprecation warnings concerning inner constructors on Julia 0.6
See JuliaLang/julia#20308.
1 parent 0fdff06 commit f6cd3b6

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

src/ACME.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,14 @@ type DiscreteModel{Solver}
316316
solver::Solver
317317
x::Vector{Float64}
318318

319-
function DiscreteModel(circ::Circuit, t::Float64)
319+
@compat function (::Type{DiscreteModel{Solver}}){Solver}(circ::Circuit, t::Float64)
320320
Base.depwarn("DiscreteModel{Solver}(circ, t) is deprecated, use DiscreteModel(circ, t, Solver) instead.",
321321
:DiscreteModel)
322322
DiscreteModel(circ, t, Solver)
323323
end
324324

325-
function DiscreteModel(mats::Dict{Symbol}, nonlinear_eq::Expr, solver::Solver)
326-
model = new()
325+
@compat function (::Type{DiscreteModel{Solver}}){Solver}(mats::Dict{Symbol}, nonlinear_eq::Expr, solver::Solver)
326+
model = new{Solver}()
327327

328328
for mat in (:a, :b, :c, :pexp, :dq, :eq, :fq, :dy, :ey, :fy, :x0, :q0, :y0)
329329
setfield!(model, mat, convert(fieldtype(typeof(model), mat), mats[mat]))
@@ -584,12 +584,12 @@ immutable ModelRunner{Model<:DiscreteModel,ShowProgress}
584584
p::Vector{Float64}
585585
ycur::Vector{Float64}
586586
xnew::Vector{Float64}
587-
function ModelRunner(model::Model)
587+
@compat function (::Type{ModelRunner{Model,ShowProgress}}){Model<:DiscreteModel,ShowProgress}(model::Model)
588588
ucur = Array{Float64,1}(nu(model))
589589
p = Array{Float64,1}(np(model))
590590
ycur = Array{Float64,1}(ny(model))
591591
xnew = Array{Float64,1}(nx(model))
592-
return new(model, ucur, p, ycur, xnew)
592+
return new{Model,ShowProgress}(model, ucur, p, ycur, xnew)
593593
end
594594
end
595595

src/solvers.jl

+23-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2016 Martin Holters
1+
# Copyright 2016, 2017 Martin Holters
22
# See accompanying license file.
33

44
export SimpleSolver, HomotopySolver, CachingSolver
@@ -12,12 +12,16 @@ type ParametricNonLinEq{F_eval<:Function,F_setp<:Function,F_calcjp<:Function,Scr
1212
Jp::Matrix{Float64}
1313
J::Matrix{Float64}
1414
scratch::Scratch
15-
function ParametricNonLinEq(func::F_eval, set_p::F_setp, calc_Jp::F_calcjp,
16-
scratch::Scratch, nn::Integer, np::Integer)
15+
@compat function (::Type{ParametricNonLinEq{F_eval,F_setp,F_calcjp,Scratch}}){
16+
F_eval<:Function,F_setp<:Function,F_calcjp<:Function,Scratch
17+
}(
18+
func::F_eval, set_p::F_setp, calc_Jp::F_calcjp, scratch::Scratch,
19+
nn::Integer, np::Integer
20+
)
1721
res = zeros(nn)
1822
Jp = zeros(nn, np)
1923
J = zeros(nn, nn)
20-
return new(func, set_p, calc_Jp, res, Jp, J, scratch)
24+
return new{F_eval,F_setp,F_calcjp,Scratch}(func, set_p, calc_Jp, res, Jp, J, scratch)
2125
end
2226
end
2327
ParametricNonLinEq{F_eval<:Function,F_setp<:Function,F_calcjp<:Function,
@@ -113,8 +117,8 @@ type SimpleSolver{NLEQ<:ParametricNonLinEq}
113117
tol::Float64
114118
tmp_nn::Vector{Float64}
115119
tmp_np::Vector{Float64}
116-
function SimpleSolver(nleq::NLEQ, initial_p::Vector{Float64},
117-
initial_z::Vector{Float64})
120+
@compat function (::Type{SimpleSolver{NLEQ}}){NLEQ<:ParametricNonLinEq}(
121+
nleq::NLEQ, initial_p::Vector{Float64}, initial_z::Vector{Float64})
118122
z = zeros(nn(nleq))
119123
linsolver = LinearSolver(nn(nleq))
120124
last_z = zeros(nn(nleq))
@@ -123,8 +127,8 @@ type SimpleSolver{NLEQ<:ParametricNonLinEq}
123127
last_linsolver = LinearSolver(nn(nleq))
124128
tmp_nn = zeros(nn(nleq))
125129
tmp_np = zeros(np(nleq))
126-
solver = new(nleq, z, linsolver, last_z, last_p, last_Jp, last_linsolver,
127-
0, 0.0, 1e-20, tmp_nn, tmp_np)
130+
solver = new{NLEQ}(nleq, z, linsolver, last_z, last_p, last_Jp,
131+
last_linsolver, 0, 0.0, 1e-20, tmp_nn, tmp_np)
128132
set_extrapolation_origin(solver, initial_p, initial_z)
129133
return solver
130134
end
@@ -201,12 +205,13 @@ type HomotopySolver{BaseSolver}
201205
start_p::Vector{Float64}
202206
pa::Vector{Float64}
203207
iters::Int
204-
function HomotopySolver(basesolver::BaseSolver, np::Integer)
205-
return new(basesolver, zeros(np), zeros(np), 0)
208+
@compat function (::Type{HomotopySolver{BaseSolver}}){BaseSolver}(
209+
basesolver::BaseSolver, np::Integer)
210+
return new{BaseSolver}(basesolver, zeros(np), zeros(np), 0)
206211
end
207-
function HomotopySolver(nleq::ParametricNonLinEq,
208-
initial_p::Vector{Float64},
209-
initial_z::Vector{Float64})
212+
@compat function (::Type{HomotopySolver{BaseSolver}}){BaseSolver}(
213+
nleq::ParametricNonLinEq, initial_p::Vector{Float64},
214+
initial_z::Vector{Float64})
210215
basesolver = BaseSolver(nleq, initial_p, initial_z)
211216
return HomotopySolver{typeof(basesolver)}(basesolver, np(nleq))
212217
end
@@ -274,15 +279,15 @@ type CachingSolver{BaseSolver}
274279
new_count::Int
275280
new_count_limit::Int
276281
alts::Alts{Float64}
277-
function CachingSolver(basesolver::BaseSolver, initial_p::Vector{Float64},
278-
initial_z::Vector{Float64}, nn::Integer)
282+
@compat function (::Type{CachingSolver{BaseSolver}}){BaseSolver}(basesolver::BaseSolver,
283+
initial_p::Vector{Float64}, initial_z::Vector{Float64}, nn::Integer)
279284
ps_tree = KDTree(hcat(initial_p))
280285
zs = reshape(copy(initial_z), nn, 1)
281286
alts = Alts(initial_p)
282-
return new(basesolver, ps_tree, zs, 1, 0, 2, alts)
287+
return new{BaseSolver}(basesolver, ps_tree, zs, 1, 0, 2, alts)
283288
end
284-
function CachingSolver(nleq::ParametricNonLinEq, initial_p::Vector{Float64},
285-
initial_z::Vector{Float64})
289+
@compat function (::Type{CachingSolver{BaseSolver}}){BaseSolver}(nleq::ParametricNonLinEq,
290+
initial_p::Vector{Float64}, initial_z::Vector{Float64})
286291
basesolver = BaseSolver(nleq, initial_p, initial_z)
287292
return CachingSolver{typeof(basesolver)}(basesolver, initial_p, initial_z, nn(nleq))
288293
end

0 commit comments

Comments
 (0)