Skip to content

Commit cc43377

Browse files
Merge pull request #944 from pitx-perf/FIX_isclock
Fix: make isclock robust to non TimeDomain argument
2 parents c568c0e + 1e511f8 commit cc43377

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/clock.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ discrete-time systems that assume a fixed sample time, such as PID controllers a
4040
filters.
4141
""" SolverStepClock
4242

43-
isclock(c) = @match c begin
43+
isclock(c) = isa(c, TimeDomain) && @match c begin
4444
PeriodicClock() => true
4545
_ => false
4646
end
4747

48-
issolverstepclock(c) = @match c begin
48+
issolverstepclock(c) = isa(c, TimeDomain) && @match c begin
4949
SolverStepClock() => true
5050
_ => false
5151
end
5252

53-
iscontinuous(c) = @match c begin
53+
iscontinuous(c) = isa(c, TimeDomain) && @match c begin
5454
ContinuousClock() => true
5555
_ => false
5656
end

test/clock.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ using MLStyle: @match
1919
@test isclock(PeriodicClock(; dt = 1.0))
2020
@test !isclock(Continuous())
2121
@test !isclock(SolverStepClock())
22+
@test !isclock(nothing)
2223

2324
@test !issolverstepclock(PeriodicClock(; dt = 1.0))
2425
@test !issolverstepclock(Continuous())
2526
@test issolverstepclock(SolverStepClock())
27+
@test !issolverstepclock(nothing)
2628

2729
@test !iscontinuous(PeriodicClock(; dt = 1.0))
2830
@test iscontinuous(Continuous())
2931
@test !iscontinuous(SolverStepClock())
32+
@test !iscontinuous(nothing)
3033

3134
@test is_discrete_time_domain(PeriodicClock(; dt = 1.0))
3235
@test !is_discrete_time_domain(Continuous())

0 commit comments

Comments
 (0)