diff --git a/Project.toml b/Project.toml index 22d437e83..baa3f15af 100644 --- a/Project.toml +++ b/Project.toml @@ -55,6 +55,7 @@ ChainRules = "1.58.0" ChainRulesCore = "1.18" CommonSolve = "0.2.4" ConstructionBase = "1.5" +DataFrames = "1.6" Distributed = "1.9" DocStringExtensions = "0.9" EnumX = "1" @@ -64,6 +65,7 @@ IteratorInterfaceExtensions = "^1" LinearAlgebra = "1.9" Logging = "1.9" Markdown = "1.9" +ModelingToolkit = "8.74" PartialFunctions = "1.1" PrecompileTools = "1.2" Preferences = "1.3" @@ -88,7 +90,9 @@ julia = "1.9" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" +DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" DelayDiffEq = "bcd4f6db-9728-5f36-b5f7-82caef46ccdb" +ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" PartialFunctions = "570af359-4316-4cb7-8c74-252c00c2016b" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" @@ -102,4 +106,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [targets] -test = ["Pkg", "PyCall", "PythonCall", "SafeTestsets", "Test", "StaticArrays", "StochasticDiffEq", "Aqua", "Zygote", "PartialFunctions"] +test = ["Pkg", "PyCall", "PythonCall", "SafeTestsets", "Test", "StaticArrays", "StochasticDiffEq", "Aqua", "Zygote", "PartialFunctions", "DataFrames", "ModelingToolkit", "OrdinaryDiffEq"] diff --git a/src/tabletraits.jl b/src/tabletraits.jl index 2566f528f..354405964 100644 --- a/src/tabletraits.jl +++ b/src/tabletraits.jl @@ -31,7 +31,7 @@ function Tables.rows(sol::AbstractTimeseriesSolution) names = [ :timestamp, (isempty(syms) ? (Symbol("value", i) for i in 1:N) : - (syms[i] for i in 1:N))..., + (getname(syms[i]) for i in 1:N))..., ] types = Type[eltype(sol.t), (eltype(sol.u[1]) for i in 1:N)...] else diff --git a/test/traits.jl b/test/traits.jl index b076e2a2d..5668c29e3 100644 --- a/test/traits.jl +++ b/test/traits.jl @@ -1,4 +1,5 @@ using SciMLBase, Test +using ModelingToolkit, OrdinaryDiffEq, DataFrames @test SciMLBase.Tables.isrowtable(ODESolution) @test SciMLBase.Tables.isrowtable(RODESolution) @@ -7,3 +8,14 @@ using SciMLBase, Test @test !SciMLBase.Tables.isrowtable(SciMLBase.LinearSolution) @test !SciMLBase.Tables.isrowtable(SciMLBase.QuadratureSolution) @test !SciMLBase.Tables.isrowtable(SciMLBase.OptimizationSolution) + +@variables t x(t)=1 +D = Differential(t) +eqs = [D(x) ~ -x] +@named sys = ODESystem(eqs) +prob = ODEProblem(sys) +sol = solve(prob, Tsit5(), tspan=(0.0, 1.0)) +df = DataFrame(sol) +@test size(df) == (length(sol.u), 2) +@test df.timestamp == sol.t +@test df.x == sol[x]