Skip to content

Commit 944ce50

Browse files
committed
fix tests
1 parent 9ef1fd7 commit 944ce50

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

src/callbacks.jl

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,18 @@ callbacks are collected for the whole network using `get_callbacks`.
123123
[`DiffEq.jl docs`](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/)
124124
for available options.
125125
"""
126-
struct ContinuousComponentCallback{C,CDIM,CPDIM,A,ADIM,APDIM,An,AnDIM,AnPDIM} <: ComponentCallback
127-
condition::ComponentCondition{C,CDIM,CPDIM}
128-
affect::ComponentAffect{A,ADIM,APDIM}
129-
affect_neg::Union{Nothing,ComponentAffect{An,AnDIM,AnPDIM}}
126+
struct ContinuousComponentCallback{
127+
C <: ComponentCondition,
128+
A <: ComponentAffect,
129+
An <: Union{ComponentAffect,Nothing}
130+
} <: ComponentCallback
131+
condition::C
132+
affect::A
133+
affect_neg::An
130134
kwargs::NamedTuple
131135
end
132136
function ContinuousComponentCallback(condition, affect; affect_neg! = affect, kwargs...)
133-
if affect_neg! == nothing
134-
ContinuousComponentCallback{_get_type_parameters(condition,affect)...,Nothing,Nothing,Nothing}(condition, affect, nothing, NamedTuple(kwargs))
135-
else
136-
ContinuousComponentCallback(condition, affect, affect_neg!, NamedTuple(kwargs))
137-
end
138-
end
139-
function _get_type_parameters(condition::ComponentCondition{C,CDIM,CPDIM}, affect::ComponentAffect{A,ADIM,APDIM}) where {C,CDIM,CPDIM,A,ADIM,APDIM}
140-
C, CDIM, CPDIM, A, ADIM, APDIM
137+
ContinuousComponentCallback(condition, affect, affect_neg!, NamedTuple(kwargs))
141138
end
142139

143140
"""
@@ -158,19 +155,19 @@ callbacks are collected for the whole network using [`get_callbacks(::Network)`]
158155
[`DiffEq.jl docs`](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/)
159156
for available options.
160157
"""
161-
struct VectorContinuousComponentCallback{C,CDIM,CPDIM,A,ADIM,APDIM,An,AnDIM,AnPDIM} <: ComponentCallback
162-
condition::ComponentCondition{C,CDIM,CPDIM}
163-
affect::ComponentAffect{A,ADIM,APDIM}
164-
affect_neg::Union{Nothing,ComponentAffect{An,AnDIM,AnPDIM}}
158+
struct VectorContinuousComponentCallback{
159+
C <: ComponentCondition,
160+
A <: ComponentAffect,
161+
An <: Union{ComponentAffect,Nothing}
162+
} <: ComponentCallback
163+
condition::C
164+
affect::A
165+
affect_neg::An
165166
len::Int
166167
kwargs::NamedTuple
167168
end
168169
function VectorContinuousComponentCallback(condition, affect, len; affect_neg! = affect, kwargs...)
169-
if affect_neg! == nothing
170-
VectorContinuousComponentCallback{_get_type_parameters(condition,affect)...,Nothing,Nothing,Nothing}(condition, affect, nothing, len, NamedTuple(kwargs))
171-
else
172-
VectorContinuousComponentCallback(condition, affect, affect_neg!, len, NamedTuple(kwargs))
173-
end
170+
VectorContinuousComponentCallback(condition, affect, affect_neg!, len, NamedTuple(kwargs))
174171
end
175172

176173
"""

test/callbacks_test.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ end
257257
@test_throws ArgumentError set_callback!(nw.im.edgem[1], cb)
258258
end
259259

260-
# @testset "check callbacks with different affneg" begin
261-
begin
260+
@testset "check callbacks with different affneg" begin
262261
f = (du, u, in, p, t) -> begin
263262
du[1] = -sin(t)
264263
du[2] = cos(t)

0 commit comments

Comments
 (0)