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

Forcing the most specialized iterator #92

Open
ChrisRackauckas opened this issue Apr 11, 2019 · 1 comment
Open

Forcing the most specialized iterator #92

ChrisRackauckas opened this issue Apr 11, 2019 · 1 comment

Comments

@ChrisRackauckas
Copy link

For the DifferentialEquations.jl iterator, it seems that

using OrdinaryDiffEq

f_2dlinear = (du,u,p,t) -> du.=1.01u
prob = ODEProblem(f_2dlinear,rand(2,2),(0.0,1.0))
sol1 =solve(prob,Tsit5())
using IterableTables, DataFrames
df = DataFrame(sol1)

works, but

using OrdinaryDiffEq

f_2dlinear = (du,u,p,t) -> du.=1.01u
prob = ODEProblem(f_2dlinear,rand(2),(0.0,1.0))
sol1 =solve(prob,Tsit5())
using IterableTables, DataFrames
df = DataFrame(sol1)

doesn't go through the iterator in DiffEqBase, but instead uses a generic one for a matrix (since the solution is a VectorOfArray{Vector} and is thus 2 dimensional, while the first case is 3 dimensional). This seems odd because I would've assumed it would pick the more specialized iterator that's only for DESolution, and I'm not sure where the dispatch logic on this is taking place.

@davidanthoff
Copy link
Member

This is a design decision in DataFrames.jl. Your second example triggers this constructor because sol2 isa AbstractMatrix (whereas that isn't true for sol1): DataFrame just generally handles matrix arguments differently.

Other TableTraits.jl sinks don't have this issue: converting things into DataTable from QueryTables.jl or plotting it with e.g. VegaLite.jl, or showing it with ElectronDisplay.jl all works as expected.

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

No branches or pull requests

2 participants