Skip to content

Commit edd2f85

Browse files
committed
export operator
1 parent 0badc16 commit edd2f85

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

src/ModelingToolkit.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export debug_system
268268
#export Continuous, Discrete, sampletime, input_timedomain, output_timedomain
269269
#export has_discrete_domain, has_continuous_domain
270270
#export is_discrete_domain, is_continuous_domain, is_hybrid_domain
271-
export Sample, Hold, Shift, ShiftIndex, sampletime, SampleTime
271+
export Sample, Hold, Shift, ShiftIndex, sampletime, SampleTime, ClockChange
272272
export Clock #, InferredDiscrete,
273273

274274
end # module

src/clock.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ See also [`is_discrete_domain`](@ref)
5555
"""
5656
function has_discrete_domain(x)
5757
issym(x) && return is_discrete_domain(x)
58-
hasshift(x) || hassample(x) || hashold(x)
58+
hasshift(x) || hassample(x) || hashold(x) || hasclockchange(x)
5959
end
6060

6161
"""

src/discretedomain.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ end
166166
SymbolicUtils.promote_symtype(::ClockChange, x) = x
167167

168168
function Base.:(==)(D1::ClockChange, D2::ClockChange)
169-
isequal(D1.to, D2.to) && isequal(D1.from, D2.from)
169+
==(D1.to, D2.to) && ==(D1.from, D2.from)
170170
end
171171
Base.hash(D::ClockChange, u::UInt) = hash(D.from, hash(D.to, xor(u, 0xa5b640d6d952f101)))
172-
172+
hasclockchange(O) = recursive_hasoperator(ClockChange, unwrap(O))
173173
# ShiftIndex
174174

175175
"""

src/systems/clock_inference.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,10 @@ function generate_discrete_affect(
250250
cont_to_disc_obs = build_explicit_observed_function(
251251
use_index_cache ? osys : syss[continuous_id],
252252
needed_cont_to_disc_obs,
253-
throw = false,
253+
throw = true,
254254
expression = true,
255255
output_type = SVector)
256+
256257
disc_to_cont_obs = build_explicit_observed_function(sys, needed_disc_to_cont_obs,
257258
throw = false,
258259
expression = true,

src/systems/discrete_system/discrete_system.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ function DiscreteSystem(eqs::AbstractVector{<:Equation}, iv, dvs, ps;
139139
iv′ = value(iv)
140140
dvs′ = value.(dvs)
141141
ps′ = value.(ps)
142-
if any(hasderiv, eqs) || any(hashold, eqs) || any(hassample, eqs) || any(hasdiff, eqs)
142+
if any(hasderiv, eqs) || any(hashold, eqs) || any(hassample, eqs) ||
143+
any(hasdiff, eqs) || any(hasclockchange, eqs)
143144
error("Equations in a `DiscreteSystem` can only have `Shift` operators.")
144145
end
145146
if !(isempty(default_u0) && isempty(default_p))

0 commit comments

Comments
 (0)