Skip to content

Commit

Permalink
Connection and StateMachineOperator should behave like scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
YingboMa committed Feb 21, 2024
1 parent b0d61aa commit 737c7c2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ hide_lhs(_) = false
###
### Connection
###
struct Connection <: Real
struct Connection
systems
end
Base.broadcastable(x::Connection) = (x,)
Connection() = Connection(nothing)
Base.hash(c::Connection, seed::UInt) = hash(c.systems, (0xc80093537bdc1311 % UInt) seed)
hide_lhs(_::Connection) = true
Expand All @@ -20,11 +21,13 @@ end

function Base.show(io::IO, c::Connection)
print(io, "connect(")
n = length(c.systems)
for (i, s) in enumerate(c.systems)
str = join(split(string(nameof(s)), NAMESPACE_SEPARATOR), '.')
print(io, str)
i != n && print(io, ", ")
if c.systems isa AbstractArray
n = length(c.systems)
for (i, s) in enumerate(c.systems)
str = join(split(string(nameof(s)), NAMESPACE_SEPARATOR), '.')
print(io, str)
i != n && print(io, ", ")
end
end
print(io, ")")
end
Expand All @@ -34,7 +37,8 @@ end
###
_nameof(s) = nameof(s)
_nameof(s::Union{Int, Symbol}) = s
abstract type StateMachineOperator <: Real end
abstract type StateMachineOperator end
Base.broadcastable(x::StateMachineOperator) = (x,)
hide_lhs(_::StateMachineOperator) = true
struct InitialState <: StateMachineOperator
s
Expand Down

0 comments on commit 737c7c2

Please sign in to comment.