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

support Symbolics.jl >v6.15.1 #279

Closed
oameye opened this issue Oct 24, 2024 · 2 comments
Closed

support Symbolics.jl >v6.15.1 #279

oameye opened this issue Oct 24, 2024 · 2 comments
Labels
dependency issue This issue is caused by a dependency.

Comments

@oameye
Copy link
Member

oameye commented Oct 24, 2024

This PR in symbolics break HB.jl.

@oameye oameye added bug Something isn't working dependency issue This issue is caused by a dependency. and removed bug Something isn't working labels Oct 24, 2024
@oameye
Copy link
Member Author

oameye commented Oct 27, 2024

# Taken from Symbolics.jl and reduced to the minimum necessary for the code to work for param and variables.
# https://github.com/JuliaSymbolics/Symbolics.jl/blob/c3f54a60c3b708ed33411a431d040de3a02d5f3d/src/latexify_recipes.jl#L140
# Symbolics._toexpr does \\mathtt{var} for variables
# see https://github.com/JuliaSymbolics/Symbolics.jl/pull/1305
function _toexpr(O)
    if Symbolics.issym(O)
        sym = string(nameof(O))
        return Symbol(replace(sym, Symbolics.NAMESPACE_SEPARATOR => "."))
    end
    !Symbolics.iscall(O) && return O

    op = Symbolics.operation(O)
    args = Symbolics.sorted_arguments(O)

    if (op===(*)) && (args[1] === -1)
        arg_mul = Expr(:call, :(*), _toexpr(args[2:end])...)
        return Expr(:call, :(-), arg_mul)
    end

    if Symbolics.symtype(op) <: Symbolics.FnType
        isempty(args) && return nameof(op)
        return Expr(:call, _toexpr(op), _toexpr(args)...)
    elseif Symbolics.issym(op) &&  Symbolics.symtype(op) <: AbstractArray
        return :(_textbf($(nameof(op))))
    elseif op === identity
        return _toexpr(only(args)) # suppress identity transformations (e.g. "identity(π)" -> "π")
    end
    return Expr(:call, Symbol(op), _toexpr(args)...)
end
_toexpr(O::Num) = _toexpr(O.val)

@oameye
Copy link
Member Author

oameye commented Oct 27, 2024

solved by #292

@oameye oameye closed this as completed Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency issue This issue is caused by a dependency.
Projects
None yet
Development

No branches or pull requests

1 participant