Skip to content

Commit 7f8aac6

Browse files
committed
Actually define promote_symtype
1 parent c6a403a commit 7f8aac6

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/equations.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ struct Equation
1414
end
1515
Base.:(==)(a::Equation, b::Equation) = all(isequal.((a.lhs, a.rhs), (b.lhs, b.rhs)))
1616
Base.hash(a::Equation, salt::UInt) = hash(a.lhs, hash(a.rhs, salt))
17+
1718
Base.show(io::IO, eq::Equation) = print(io, eq.lhs, " ~ ", eq.rhs)
1819

1920
SymbolicUtils.simplify(x::Equation; kw...) = simplify(x.lhs; kw...) ~ simplify(x.rhs; kw...)

src/extra_functions.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@register Base.getindex(x,i::Integer)
2-
@register Base.getindex(x,i)
1+
@register Base.getindex(x,i::Integer) false
2+
@register Base.getindex(x,i) false
33
@register Base.binomial(n,k)
44

55
@register Base.signbit(x)
@@ -36,8 +36,8 @@ ModelingToolkit.@register Distributions.cdf(dist,x)
3636
ModelingToolkit.@register Distributions.logcdf(dist,x)
3737
ModelingToolkit.@register Distributions.quantile(dist,x)
3838

39-
ModelingToolkit.@register Distributions.Uniform(mu,sigma)
40-
ModelingToolkit.@register Distributions.Normal(mu,sigma)
39+
ModelingToolkit.@register Distributions.Uniform(mu,sigma) false
40+
ModelingToolkit.@register Distributions.Normal(mu,sigma) false
4141

4242
@register (x::Num, y::AbstractArray)
4343
@register (x, y)

src/register_function.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
@register(expr, Ts = [Num, Symbolic, Real])
2+
@register(expr, define_promotion, Ts = [Num, Symbolic, Real])
33
44
Overload approperate methods such that ModelingToolkit can stop tracing into the
55
registered function.
@@ -11,7 +11,7 @@ registered function.
1111
@register hoo(x, y)::Int # `hoo` returns `Int`
1212
```
1313
"""
14-
macro register(expr, Ts = [Num, Symbolic, Real])
14+
macro register(expr, define_promotion = true, Ts = [Num, Symbolic, Real])
1515
if expr.head === :(::)
1616
ret_type = expr.args[2]
1717
expr = expr.args[1]
@@ -48,7 +48,7 @@ macro register(expr, Ts = [Num, Symbolic, Real])
4848
push!(
4949
ex.args,
5050
quote
51-
if $!($hasmethod($promote_symtype, $Tuple{$typeof($f), $Vararg}))
51+
if $define_promotion
5252
(::$typeof($promote_symtype))(::$typeof($f), args...) = $ret_type
5353
end
5454
end

0 commit comments

Comments
 (0)