Skip to content

Commit 7e901bf

Browse files
Add nameof dispatches on operators
This previously relied on `Operator <: Function` and `Function` just happens to have `nameof` defined.
1 parent 59cd46b commit 7e901bf

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1.0, 2"
109109
StaticArrays = "0.10, 0.11, 0.12, 1.0"
110110
SymbolicIndexingInterface = "0.3.12"
111111
SymbolicUtils = "2.1"
112-
Symbolics = "5.30.1"
112+
Symbolics = "5.32"
113113
URIs = "1"
114114
UnPack = "0.1, 1.0"
115115
Unitful = "1.1"

src/discretedomain.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ struct SampleTime <: Operator
44
SampleTime() = SymbolicUtils.term(SampleTime, type = Real)
55
end
66
SymbolicUtils.promote_symtype(::Type{<:SampleTime}, t...) = Real
7+
Base.nameof(::SampleTime) = :SampleTime
78

89
# Shift
910

@@ -32,6 +33,8 @@ struct Shift <: Operator
3233
end
3334
Shift(steps::Int) = new(nothing, steps)
3435
normalize_to_differential(s::Shift) = Differential(s.t)^s.steps
36+
Base.nameof(::Shift) = :Shift
37+
3538
function (D::Shift)(x, allow_zero = false)
3639
!allow_zero && D.steps == 0 && return x
3740
Term{symtype(x)}(D, Any[x])
@@ -108,6 +111,7 @@ Sample(x) = Sample()(x)
108111
(D::Sample)(x) = Term{symtype(x)}(D, Any[x])
109112
(D::Sample)(x::Num) = Num(D(value(x)))
110113
SymbolicUtils.promote_symtype(::Sample, x) = x
114+
Base.nameof(::Sample) = :Sample
111115

112116
Base.show(io::IO, D::Sample) = print(io, "Sample(", D.clock, ")")
113117

@@ -137,6 +141,7 @@ end
137141
(D::Hold)(x) = Term{symtype(x)}(D, Any[x])
138142
(D::Hold)(x::Num) = Num(D(value(x)))
139143
SymbolicUtils.promote_symtype(::Hold, x) = x
144+
Base.nameof(::Hold) = :Hold
140145

141146
Hold(x) = Hold()(x)
142147

0 commit comments

Comments
 (0)