Skip to content

Commit

Permalink
Merge pull request #944 from pitx-perf/FIX_isclock
Browse files Browse the repository at this point in the history
Fix: make isclock robust to non TimeDomain argument
  • Loading branch information
ChrisRackauckas authored Feb 28, 2025
2 parents c568c0e + 1e511f8 commit cc43377
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/clock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ discrete-time systems that assume a fixed sample time, such as PID controllers a
filters.
""" SolverStepClock

isclock(c) = @match c begin
isclock(c) = isa(c, TimeDomain) && @match c begin
PeriodicClock() => true
_ => false
end

issolverstepclock(c) = @match c begin
issolverstepclock(c) = isa(c, TimeDomain) && @match c begin
SolverStepClock() => true
_ => false
end

iscontinuous(c) = @match c begin
iscontinuous(c) = isa(c, TimeDomain) && @match c begin
ContinuousClock() => true
_ => false
end
Expand Down
3 changes: 3 additions & 0 deletions test/clock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ using MLStyle: @match
@test isclock(PeriodicClock(; dt = 1.0))
@test !isclock(Continuous())
@test !isclock(SolverStepClock())
@test !isclock(nothing)

@test !issolverstepclock(PeriodicClock(; dt = 1.0))
@test !issolverstepclock(Continuous())
@test issolverstepclock(SolverStepClock())
@test !issolverstepclock(nothing)

@test !iscontinuous(PeriodicClock(; dt = 1.0))
@test iscontinuous(Continuous())
@test !iscontinuous(SolverStepClock())
@test !iscontinuous(nothing)

@test is_discrete_time_domain(PeriodicClock(; dt = 1.0))
@test !is_discrete_time_domain(Continuous())
Expand Down

0 comments on commit cc43377

Please sign in to comment.