Skip to content

Implement table traits for DiffEq arrays - #222

Merged
ChrisRackauckas merged 2 commits into
masterfrom
dw/tabletraits
Aug 11, 2022
Merged

ChrisRackauckas merged 2 commits into
masterfrom
dw/tabletraits

Conversation

@devmotion

Copy link
Copy Markdown
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  
─────┼────────────────────────────────────────────────────
   1 │    0.0     0.494427  0.12895   0.0152497  0.330754
   2 │    0.0625  0.525638  0.13709   0.0162124  0.351633
   3 │    0.125   0.558819  0.145744  0.0172358  0.373829
   4 │    0.1875  0.594094  0.154944  0.0183238  0.397427
   5 │    0.25    0.631596  0.164724  0.0194805  0.422515
   6 │    0.3125  0.671466  0.175123  0.0207102  0.449186
   7 │    0.375   0.713852  0.186177  0.0220175  0.477541
   8 │    0.4375  0.758914  0.19793   0.0234074  0.507686
   9 │    0.5     0.806821  0.210424  0.024885   0.539734
  10 │    0.5625  0.857751  0.223707  0.0264558  0.573804
  11 │    0.625   0.911897  0.237828  0.0281259  0.610026
  12 │    0.6875  0.96946   0.252841  0.0299013  0.648534
  13 │    0.75    1.03066   0.268802  0.0317888  0.689472
  14 │    0.8125  1.09572   0.28577   0.0337955  0.732995
  15 │    0.875   1.16488   0.303809  0.0359288  0.779265
  16 │    0.9375  1.23842   0.322987  0.0381968  0.828457
  17 │    1.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  
─────┼────────────────────────────────────────────────────
   1 │       0.0  0.494427  0.12895   0.0152497  0.330754
   2 │       0.1  0.545245  0.142203  0.0168171  0.364749
   3 │       0.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