Skip to content

Commit

Permalink
Merge pull request #1027 from JuliaSymbolics/registration_using
Browse files Browse the repository at this point in the history
Fix registration without using
  • Loading branch information
ChrisRackauckas authored Dec 27, 2023
2 parents 9975197 + 494f269 commit 713052a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/extra_functions.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@register_symbolic Base.binomial(n, k)::Int true [Integer]
@register_symbolic Base.binomial(n, k::Integer)::Int true

@register_symbolic Base.sign(x)::Int
derivative(::typeof(sign), args::NTuple{1,Any}, ::Val{1}) = 0
Expand Down
2 changes: 1 addition & 1 deletion src/register.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ macro register_symbolic(expr, define_promotion = true, Ts = :([]))
args′ = map((a, T) -> :($a::$T), argnames, Ts)
ret_type = isnothing(ret_type) ? Real : ret_type

fexpr = :(@wrapped function $f($(args′...))
fexpr = :(Symbolics.@wrapped function $f($(args′...))
args = [$(argnames...),]
unwrapped_args = map($unwrap, args)
res = if !any(x->$issym(x) || $istree(x), unwrapped_args)
Expand Down
4 changes: 2 additions & 2 deletions src/wrapper-types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ function wrap_func_expr(mod, expr)
# expected to be defined outside Symbolics
if arg isa Expr && arg.head == :(::)
T = Base.eval(mod, arg.args[2])
has_symwrapper(T) ? (T, :(SymbolicUtils.Symbolic{<:$T}), wrapper_type(T)) :
(T,:(SymbolicUtils.Symbolic{<:$T}))
has_symwrapper(T) ? (T, :(Symbolics.SymbolicUtils.Symbolic{<:$T}), wrapper_type(T)) :
(T,:(Symbolics.SymbolicUtils.Symbolic{<:$T}))
elseif arg isa Expr && arg.head == :(...)
Ts = type_options(arg.args[1])
map(x->Vararg{x},Ts)
Expand Down
1 change: 1 addition & 0 deletions test/registration_without_using.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import Symbolics;Symbolics.@register_symbolic foo(x, y)
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ if GROUP == "All" || GROUP == "Core"
@safetestset "Integral Test" begin include("integral.jl") end
@safetestset "CartesianIndex Test" begin include("cartesianindex.jl") end
@safetestset "LogExpFunctions Test" begin include("logexpfunctions.jl") end
@safetestset "Registration without using Test" begin include("registration_without_using.jl") end
end

if GROUP == "All" || GROUP == "Core" || GROUP == "SymbolicIndexingInterface"
Expand Down

0 comments on commit 713052a

Please sign in to comment.