You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SciMLBaseMakieExt causes Makie recipes using SciML types to fail miserably if not safe guarding against it.
Expected behavior
I would have expected that I am allowed to define my own plot type that takes a SciML type as input without further actions.
Minimal Reproducible Example 👇
Without MRE, we would only be able to help you to a limited extent, and attention to the issue would be limited. to know more about MRE refer to wikipedia and stackoverflow.
using GLMakie, OrdinaryDiffEq, SciMLBase
#get an example AbstractODESolution
u0 =1.0
tspan = (0.0, 1.0)
f(u, p, t) =- u
prob =ODEProblem(f, u0, tspan)
sol =solve(prob, Tsit5())
#define a makie recipe, see here:#https://docs.makie.org/stable/explanations/recipes/index.html@recipe(MyPlot) do scene
Theme(
plot_color =:red
)
endfunction Makie.plot!(myplot::MyPlot)
t = myplot[1][].t
u = myplot[1][][1,:]
@show t, u
plot!(myplot, t, u) #just plots t vs u(t); as an examplereturn myplot
endmyplot(sol) #fails, see stacktrace
Error & Stacktrace ⚠️
ERROR:`Makie.convert_arguments`for the plot type Plot{myplot} and its conversion trait NoConversion() was unsuccessful.
There is a recipe for the given arguments and the `PointBased` trait, however.
The signature that could not be converted was:
::ODESolution{Float64, 1, Vector{Float64}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Float64}}, ODEProblem{Float64, Tuple{Float64, Float64}, false, SciMLBase.NullParameters, ODEFunction{false, SciMLBase.AutoSpecialize, typeof(f), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, SymbolicIndexingInterface.SymbolCache{Nothing, Nothing, Nothing}, Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}, SciMLBase.StandardODEProblem}, Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{ODEFunction{false, SciMLBase.AutoSpecialize, typeof(f), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, SymbolicIndexingInterface.SymbolCache{Nothing, Nothing, Nothing}, Nothing, Nothing}, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, Nothing, OrdinaryDiffEq.Tsit5ConstantCache, Nothing}, SciMLBase.DEStats, Nothing}
Makie needs to convert all plot input arguments to types that can be consumed by the backends (typically Arrays with Float32 elements).
You can define a method for`Makie.convert_arguments` (a type recipe) for these types or their supertypes to make this set of arguments convertible (See http://docs.makie.org/stable/documentation/recipes/index.html).
Alternatively, you can define `Makie.convert_single_argument`for single arguments which have types that are unknown to Makie but which can be converted to known types and fed back to the conversion pipeline.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:35
[2] ensure_plottrait(PT::Type, arg::ODESolution{…}, desired_plottrait_type::Type)
@ SciMLBaseMakieExt C:\Users\thvt\.julia\packages\SciMLBase\Dwomw\ext\SciMLBaseMakieExt.jl:10
[3] convert_arguments(PT::Type{…}, sol::ODESolution{…}; plot_analytic::Bool, denseplot::MakieCore.Automatic, plotdensity::MakieCore.Automatic, plotat::Nothing, tspan::Nothing, tscale::Symbol, vars::Nothing, idxs::Nothing)
@ SciMLBaseMakieExt C:\Users\thvt\.julia\packages\SciMLBase\Dwomw\ext\SciMLBaseMakieExt.jl:59
[4] convert_arguments(PT::Type{…}, sol::ODESolution{…})
@ SciMLBaseMakieExt C:\Users\thvt\.julia\packages\SciMLBase\Dwomw\ext\SciMLBaseMakieExt.jl:38
[5] (Plot{myplot})(args::Tuple{ODESolution{…}}, plot_attributes::Dict{Symbol, Any})
@ Makie C:\Users\thvt\.julia\packages\Makie\VRavR\src\interfaces.jl:142
[6] _create_plot(F::Function, attributes::Dict{…}, args::ODESolution{…})
@ Makie C:\Users\thvt\.julia\packages\Makie\VRavR\src\figureplotting.jl:248
[7] myplot(args::ODESolution{…}; kw::@Kwargs{})
@ Main C:\Users\thvt\.julia\packages\MakieCore\UAwps\src\recipes.jl:175
[8] top-level scope
@ REPL[15]:1
Some type information was truncated. Use `show(err)` to see complete types.
Environment (please complete the following information):
Output of using Pkg; Pkg.status()
Status `C:\Users\thvt\H. Lundbeck A S\GWS SFS - Documents\Models\Thomas\testfolder\Project.toml`
[e9467ef8] GLMakie v0.9.9
[1dea7af3] OrdinaryDiffEq v6.74.0
[0bca4576] SciMLBase v2.29.0
Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Dispatching like this also includes custom plot types (e.g., from recipes) to be included. Indeed, continuing the above MWE with:
#if we define what is essentially a no-op, then it can be brought to work.function Makie.convert_arguments(::Type{<:Plot{myplot}}, sol::SciMLBase.AbstractODESolution)
return (sol, )
endmyplot(sol) #works
It can be brought back to work. However, in my opinion, it doesn't really fell nice to impose this kind of "hack" on someone defining their own plot type with a recipe. Can the dispatch in SciMLBase maybe be narrowed down?
The text was updated successfully, but these errors were encountered:
Describe the bug 🐞
The SciMLBaseMakieExt causes Makie recipes using SciML types to fail miserably if not safe guarding against it.
Expected behavior
I would have expected that I am allowed to define my own plot type that takes a SciML type as input without further actions.
Minimal Reproducible Example 👇
Without MRE, we would only be able to help you to a limited extent, and attention to the issue would be limited. to know more about MRE refer to wikipedia and stackoverflow.
Error & Stacktrace⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context
The problem likely has to do with being a little, ahem..., liberal with dispatching
Makie.convert_arguments(...)
on to every plot type known to Makie: https://github.com/SciML/SciMLBase.jl/blob/master/ext/SciMLBaseMakieExt.jl#L38Dispatching like this also includes custom plot types (e.g., from recipes) to be included. Indeed, continuing the above MWE with:
It can be brought back to work. However, in my opinion, it doesn't really fell nice to impose this kind of "hack" on someone defining their own plot type with a recipe. Can the dispatch in SciMLBase maybe be narrowed down?
The text was updated successfully, but these errors were encountered: