I have a problem that fails due to Num
(from Symbolics.jl) not being automatically wrapped by RCall.jl. Here’s a minimal example that throws the error:
using Symbolics
using RCall
@variables x
@rput x
ERROR: MethodError: no method matching sexpclass(::Num)
Closest candidates are:
sexpclass(::SubArray{<:Any, <:Any, <:CategoricalArrays.CategoricalArray})
@ RCall ~/.julia/packages/RCall/dDAVd/src/convert/default.jl:271
sexpclass(::Tuple)
@ RCall ~/.julia/packages/RCall/dDAVd/src/convert/tuple.jl:25
sexpclass(::AbstractDict)
@ RCall ~/.julia/packages/RCall/dDAVd/src/convert/default.jl:250
I’ve looked at the RCall docs, and have tried a few things, but nothing has worked so far. Num
is defined as follows:
@symbolic_wrap struct Num <: Real
val
end
and @symbolic_wrap
defined as:
macro symbolic_wrap(expr)
@assert expr isa Expr && expr.head == :struct
@assert expr.args[2].head == :(<:)
sig = expr.args[2]
T = getname(sig.args[1])
supertype = set_where(sig.args[1], sig.args[2])
quote
$expr
Symbolics.has_symwrapper(::Type{<:$supertype}) = true
Symbolics.wrapper_type(::Type{<:$supertype}) = $T
Symbolics.is_wrapper_type(::Type{<:$T}) = true # used in `@register`
Symbolics.wraps_type(::Type{$T}) = $supertype
Symbolics.iswrapped(::$T) = true
end |> esc
end
I know I have to define sexpclass
and sexp
, but a starting place would be great (the wrapping adds some complexity from the example in the RCall.jl docs)