Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use register symbolic for interpolation objects #318

Merged
merged 2 commits into from
Jul 29, 2024

Conversation

sathvikbhagavan
Copy link
Member

fixes: #317

It was missing a dispatch:

(interp::AbstractInterpolation)(t::BasicSymbolic) = SymbolicUtils.term(interp, t)

But then all of them can be combined to just use register_symbolic as it does the same thing:

ulia> @macroexpand @register_symbolic A(t)
quote
    begin
        #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/wrapper-types.jl:151 =#
        function A_10851946841911346439(nothing, t)
            #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/wrapper-types.jl:124 =#
            #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/wrapper-types.jl:125 =#
            begin
                #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/register.jl:32 =#
                #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/register.jl:33 =#
                args = [t]
                #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/register.jl:34 =#
                unwrapped_args = map(Symbolics.unwrap, args)
                #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/register.jl:35 =#
                res = if !(any((x->begin
                                        #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/register.jl:35 =#
                                        (TermInterface.issym)(x) || (TermInterface.iscall)(x)
                                    end), unwrapped_args))
                        #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/register.jl:36 =#
                        A(unwrapped_args...)
                    else
                        #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/register.jl:38 =#
                        (SymbolicUtils.Term){Real}(A, unwrapped_args)
                    end
                #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/register.jl:40 =#
                if typeof.(args) == typeof.(unwrapped_args)
                    #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/register.jl:41 =#
                    return res
                else
                    #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/register.jl:43 =#
                    return (Symbolics.wrap)(res)
                end
            end
        end
        #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/wrapper-types.jl:152 =#
        function A(t::Symbolics.SymbolicUtils.Symbolic{<:Real})
            #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/wrapper-types.jl:140 =#
            #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/wrapper-types.jl:141 =#
            if any(Symbolics.iswrapped, (t,))
                #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/wrapper-types.jl:134 =#
                (Symbolics.wrap)(A_10851946841911346439(nothing, (Symbolics.unwrap)(t)))
            else
                #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/wrapper-types.jl:136 =#
                A_10851946841911346439(nothing, t)
            end
        end
        function A(t::Num)
            #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/wrapper-types.jl:140 =#
            #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/wrapper-types.jl:141 =#
            if any(Symbolics.iswrapped, (t,))
                #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/wrapper-types.jl:134 =#
                (Symbolics.wrap)(A_10851946841911346439(nothing, (Symbolics.unwrap)(t)))
            else
                #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/wrapper-types.jl:136 =#
                A_10851946841911346439(nothing, t)
            end
        end
    end
    #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/register.jl:48 =#
    (::(typeof)(SymbolicUtils.promote_symtype))(::(typeof)(A), args...) = begin
            #= /home/sathvikbhagavan/.julia/packages/Symbolics/f5Y9e/src/register.jl:48 =#
            Real
        end
end

@ChrisRackauckas ChrisRackauckas merged commit 4ee7210 into SciML:master Jul 29, 2024
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatic Jacobian sparsity detection fails when concatenating interpolations
2 participants