Skip to content

Implement table traits for DiffEq arrays #222

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

Merged
merged 2 commits into from
Aug 11, 2022
Merged

Conversation

devmotion
Copy link
Member

Fixes #211. With this PR, the example in the issue works as expected:

julia> using OrdinaryDiffEq, DataFrames

julia> f_2dlinear = (du,u,p,t) -> du.=1.01u;

julia> prob = ODEProblem(f_2dlinear,rand(2,2),(0.0,1.0));

julia> sol1 =solve(prob,Euler();dt=1//2^(4));

julia> df = DataFrame(sol1)
17×5 DataFrame
 Row │ timestamp  value1    value2    value3     value4   
     │ Float64    Float64   Float64   Float64    Float64  
─────┼────────────────────────────────────────────────────
   10.0     0.494427  0.12895   0.0152497  0.330754
   20.0625  0.525638  0.13709   0.0162124  0.351633
   30.125   0.558819  0.145744  0.0172358  0.373829
   40.1875  0.594094  0.154944  0.0183238  0.397427
   50.25    0.631596  0.164724  0.0194805  0.422515
   60.3125  0.671466  0.175123  0.0207102  0.449186
   70.375   0.713852  0.186177  0.0220175  0.477541
   80.4375  0.758914  0.19793   0.0234074  0.507686
   90.5     0.806821  0.210424  0.024885   0.539734
  100.5625  0.857751  0.223707  0.0264558  0.573804
  110.625   0.911897  0.237828  0.0281259  0.610026
  120.6875  0.96946   0.252841  0.0299013  0.648534
  130.75    1.03066   0.268802  0.0317888  0.689472
  140.8125  1.09572   0.28577   0.0337955  0.732995
  150.875   1.16488   0.303809  0.0359288  0.779265
  160.9375  1.23842   0.322987  0.0381968  0.828457
  171.0     1.31659   0.343376  0.040608   0.880753

julia> time_ = [0.0, 0.1, 0.2]
3-element Vector{Float64}:
 0.0
 0.1
 0.2

julia> DataFrame(sol1(time_))
3×5 DataFrame
 Row │ timestamp  value1    value2    value3     value4   
     │ Float64    Float64   Float64   Float64    Float64  
─────┼────────────────────────────────────────────────────
   10.0  0.494427  0.12895   0.0152497  0.330754
   20.1  0.545245  0.142203  0.0168171  0.364749
   30.2  0.601519  0.15688   0.0185528  0.402394

@ChrisRackauckas ChrisRackauckas merged commit 1607409 into master Aug 11, 2022
@ChrisRackauckas ChrisRackauckas deleted the dw/tabletraits branch August 11, 2022 18:03
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.

Convert interface to DataFrame
2 participants