Skip to content

Commit 4050534

Browse files
authored
Merge pull request #314 from JuliaDynamics/hw/deprecated
mv deprecated stuff to separate file
2 parents 8e725c1 + 6f31fa0 commit 4050534

File tree

5 files changed

+39
-35
lines changed

5 files changed

+39
-35
lines changed

src/NetworkDynamics.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ include("symbolicindexing.jl")
7575

7676
export ComponentCondition, ComponentAffect
7777
export ContinuousComponentCallback, VectorContinuousComponentCallback
78-
# Export deprecated aliases (constants defined at bottom of callbacks.jl)
79-
export ContinousComponentCallback, VectorContinousComponentCallback
8078
export DiscreteComponentCallback, PresetTimeComponentCallback
8179
export SymbolicView
8280
include("callbacks.jl")
@@ -176,4 +174,10 @@ using PrecompileTools: @compile_workload
176174
include("precompile_workload.jl")
177175
end
178176

177+
####
178+
#### Deprecated functionality (remove in breaking version)
179+
####
180+
export ContinousComponentCallback, VectorContinousComponentCallback
181+
include("deprecated.jl")
182+
179183
end

src/callbacks.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,3 @@ function assert_cb_compat(comp::ComponentModel, cb)
727727
cb
728728
end
729729

730-
####
731-
#### Backward compatibility aliases for old misspellings (deprecated)
732-
####
733-
const ContinousComponentCallback = ContinuousComponentCallback
734-
const VectorContinousComponentCallback = VectorContinuousComponentCallback

src/deprecated.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Deprecated non plural methods
2+
@deprecate delete_initconstraint!(args...; kwargs...) delete_initconstraints!(args...; kwargs...)
3+
@deprecate delete_initformula!(args...; kwargs...) delete_initformulas!(args...; kwargs...)
4+
5+
# Deprecated names with typos
6+
const ContinousComponentCallback = ContinuousComponentCallback
7+
const VectorContinousComponentCallback = VectorContinuousComponentCallback
8+
9+
# Deprecated symbolic indexing methods
10+
vidxs(compfilter::Union{Int,AbstractVector{Int},NTuple{<:Any,Int},Colon}, varfilter) = _deprecated_idxs_gen(VIndex, compfilter, varfilter)
11+
eidxs(compfilter::Union{Int,AbstractVector{Int},NTuple{<:Any,Int},Colon}, varfilter) = _deprecated_idxs_gen(EIndex, compfilter, varfilter)
12+
vpidxs(compfilter::Union{Int,AbstractVector{Int},NTuple{<:Any,Int},Colon}, varfilter) = _deprecated_idxs_gen(VPIndex, compfilter, varfilter, VIndex)
13+
epidxs(compfilter::Union{Int,AbstractVector{Int},NTuple{<:Any,Int},Colon}, varfilter) = _deprecated_idxs_gen(EPIndex, compfilter, varfilter, EIndex)
14+
15+
function _deprecated_idxs_gen(constructor, compiter, variter, type=constructor)
16+
@warn "*idxs(compfilter, varfilter) methods are deprecated. Use *idxs(nw, compfilter, varfilter) instead."
17+
if compiter isa Colon
18+
throw(ArgumentError("compfilter cannot be `:`, use *idxs(nw_like_thing, ...) for that!"))
19+
end
20+
if variter isa Colon
21+
throw(ArgumentError("varfilter cannot be `:`, use *idxs(nw_like_thing, ...) for that!"))
22+
end
23+
if variter isa Symbol
24+
variter = (variter,)
25+
end
26+
indices = type[]
27+
for ci in compiter
28+
for si in variter
29+
push!(indices, constructor(ci, si))
30+
end
31+
end
32+
indices
33+
end

src/metadata.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -799,9 +799,6 @@ delete_initformulas!(c::ComponentModel) = delete_metadata!(c, :initformula)
799799
delete_initformulas!(nw::Network, idx::VCIndex) = delete_initformulas!(getcomp(nw, idx))
800800
delete_initformulas!(nw::Network, idx::ECIndex) = delete_initformulas!(getcomp(nw, idx))
801801

802-
# Deprecated backward compatibility
803-
@deprecate delete_initconstraint!(args...; kwargs...) delete_initconstraints!(args...; kwargs...)
804-
@deprecate delete_initformula!(args...; kwargs...) delete_initformulas!(args...; kwargs...)
805802

806803

807804
# generate methods and docstrings for position and marker

src/symbolicindexing.jl

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -632,31 +632,6 @@ function epidxs(nw, cf=:, vf=nothing; kwargs...)
632632
generate_indices(nw, EIndex(cf), vf; s=false, p=true, in=false, out=false, obs=false, kwargs...)
633633
end
634634

635-
# deprecated methods
636-
vidxs(compfilter::Union{Int,AbstractVector{Int},NTuple{<:Any,Int},Colon}, varfilter) = _deprecated_idxs_gen(VIndex, compfilter, varfilter)
637-
eidxs(compfilter::Union{Int,AbstractVector{Int},NTuple{<:Any,Int},Colon}, varfilter) = _deprecated_idxs_gen(EIndex, compfilter, varfilter)
638-
vpidxs(compfilter::Union{Int,AbstractVector{Int},NTuple{<:Any,Int},Colon}, varfilter) = _deprecated_idxs_gen(VPIndex, compfilter, varfilter, VIndex)
639-
epidxs(compfilter::Union{Int,AbstractVector{Int},NTuple{<:Any,Int},Colon}, varfilter) = _deprecated_idxs_gen(EPIndex, compfilter, varfilter, EIndex)
640-
641-
function _deprecated_idxs_gen(constructor, compiter, variter, type=constructor)
642-
@warn "*idxs(compfilter, varfilter) methods are deprecated. Use *idxs(nw, compfilter, varfilter) instead."
643-
if compiter isa Colon
644-
throw(ArgumentError("compfilter cannot be `:`, use *idxs(nw_like_thing, ...) for that!"))
645-
end
646-
if variter isa Colon
647-
throw(ArgumentError("varfilter cannot be `:`, use *idxs(nw_like_thing, ...) for that!"))
648-
end
649-
if variter isa Symbol
650-
variter = (variter,)
651-
end
652-
indices = type[]
653-
for ci in compiter
654-
for si in variter
655-
push!(indices, constructor(ci, si))
656-
end
657-
end
658-
indices
659-
end
660635

661636

662637
####

0 commit comments

Comments
 (0)