diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 000000000..b28b68b85 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,38 @@ +name: CI +on: + pull_request: + branches: + - master + push: + branches: + - master +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + group: + - Core + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: 1 + - uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-runtest@v1 + env: + GROUP: ${{ matrix.group }} + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: lcov.info diff --git a/Project.toml b/Project.toml index 08f32085c..f5452b46e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,12 +1,13 @@ name = "SciMLBase" uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462" authors = ["Chris Rackauckas and contributors"] -version = "0.1.0" +version = "1.0.0" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2" DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" +IteratorInterfaceExtensions = "82899510-4779-5014-852e-03e436cf321d" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" @@ -19,6 +20,7 @@ TreeViews = "a2a6695c-b41b-5b7d-aed9-dbfdeacea5d7" [compat] ArrayInterface = "2.6" DocStringExtensions = "0.8" +IteratorInterfaceExtensions = "^0.1, ^1" RecipesBase = "0.7.0, 0.8, 1.0" RecursiveArrayTools = "2" StaticArrays = "0.11, 0.12, 1.0" @@ -27,8 +29,9 @@ TreeViews = "0.3" julia = "1" [extras] +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["SafeTestsets", "Test"] +test = ["Pkg", "SafeTestsets", "Test"] diff --git a/src/SciMLBase.jl b/src/SciMLBase.jl index 42616e499..28fb62a36 100644 --- a/src/SciMLBase.jl +++ b/src/SciMLBase.jl @@ -2,10 +2,11 @@ module SciMLBase using RecipesBase, RecursiveArrayTools, Tables, TreeViews using DocStringExtensions -import Logging, ArrayInterface using LinearAlgebra using Statistics +import Logging, ArrayInterface +import IteratorInterfaceExtensions import CommonSolve: solve, init, solve! function __solve end diff --git a/src/tabletraits.jl b/src/tabletraits.jl index 6de3a8732..871dc8910 100644 --- a/src/tabletraits.jl +++ b/src/tabletraits.jl @@ -40,3 +40,8 @@ end Tables.columnnames(x::DESolutionRow) = getfield(x, :names) Tables.getcolumn(x::DESolutionRow, i::Int) = i == 1 ? getfield(x, :t) : getfield(x, :u)[i - 1] Tables.getcolumn(x::DESolutionRow, nm::Symbol) = nm === :timestamp ? getfield(x, :t) : getfield(x, :u)[getfield(x, :lookup)[nm] - 1] + +IteratorInterfaceExtensions.isiterable(sol::DESolution) = true +IteratorInterfaceExtensions.getiterator(sol::DESolution) = + Tables.datavaluerows(Tables.rows(sol)) +#TableTraits.isiterabletable(sol::DESolution) = true diff --git a/test/remake_tests.jl b/test/remake_tests.jl deleted file mode 100644 index 9154c5beb..000000000 --- a/test/remake_tests.jl +++ /dev/null @@ -1,94 +0,0 @@ -using SciMLBase -using SciMLBase: @add_kwonly, add_kwonly -using LinearAlgebra, Test - -@add_kwonly function f(a, b; c=3, d=4) - (a, b, c, d) -end -@test f(1, 2) == (1, 2, 3, 4) -@test f(a=1, b=2) == (1, 2, 3, 4) -@test_throws ErrorException f() - -@add_kwonly g(a, b; c=3, d=4) = (a, b, c, d) -@test g(1, 2) == (1, 2, 3, 4) -@test g(a=1, b=2) == (1, 2, 3, 4) - -@add_kwonly h(; c=3, d=4) = (c, d) -@test h() == (3, 4) - -@test_throws ErrorException add_kwonly(:(i(c=3, d=4) = (c, d))) - -dprob = DiscreteProblem((u,p,t)->2u,0.5,(0.0,1.0)) -@test remake(dprob) == dprob -@test remake(dprob; u0 = 1.0).u0 == 1.0 - -oprob = ODEProblem((u,p,t)->2u,0.5,(0.0,1.0)) -@test remake(oprob) == oprob -@test remake(oprob; u0 = 1.0).u0 == 1.0 - -sprob = SDEProblem((u,p,t)->2u,(u,p,t)->2u,0.5,(0.0,1.0)) -@test remake(sprob) == sprob -@test remake(sprob; u0 = 1.0).u0 == 1.0 - -daeprob = DAEProblem((du,u,p,t)->du-2u,0.5,0.5,(0.0,1.0)) -@test remake(daeprob) == daeprob -@test remake(daeprob; u0 = 1.0).u0 == 1.0 - -ddeprob = DDEProblem((du,u,h,p,t)->-2u,0.5,(p,t)->0.0,(0.0,1.0)) -@test remake(ddeprob) == ddeprob -@test remake(daeprob; u0 = 1.0).u0 == 1.0 - -function f(du,u,p,t) - du[1] = 0.2u[1] - du[2] = 0.4u[2] -end -u0 = ones(2) -tspan = (0,1.0) - -# Create a ODEProblem and test remake: -prob1 = SplitODEProblem(f,f,u0,tspan,Dict(),callback=nothing) -prob2 = @inferred remake(prob1; u0 = prob1.u0 .+ 1) -@test prob1.f === prob2.f -@test prob1.p === prob2.p -@test prob1.u0 .+ 1 ≈ prob2.u0 -@test prob1.tspan == prob2.tspan -@test prob1.kwargs[:callback] === prob2.kwargs[:callback] -@test prob1.problem_type === prob2.problem_type - -prob2 = @inferred remake(prob1; u0 = prob1.u0 .+ 1, callback = :test) -@test prob2.kwargs[:callback] == :test - -# Test remake with SplitFunction: -prob1 = SplitODEProblem((u,p,t) -> u/2, (u,p,t) -> 2u, 1.0, (0.0,1.0)) -prob2 = remake(prob1; # prob1 is a ODEProblem - f = remake(prob1.f; # prob1.f is a SplitFunction - f2 = (u,p,t) -> 3u)) - -# Test remake with NoiseProblem (a struct w/o isinplace type parameter): -struct DummyNoiseProcess <: SciMLBase.AbstractNoiseProcess{Int,1,Nothing,true} - dummy -end -tspan1 = (0.0, 1.0) -tspan2 = (0.0, 2.0) -noise1 = NoiseProblem(DummyNoiseProcess(Dict()), tspan1); -noise2 = remake(noise1; tspan=tspan2); -@test noise1.noise === noise2.noise -@test noise1.tspan == tspan1 -@test noise2.tspan == tspan2 -@test noise1.tspan != noise2.tspan - -# Test remake with TwoPointBVPFunction (manually defined): -f1 = SciMLBase.TwoPointBVPFunction(() -> 1) -f2 = remake(f1; bc = () -> 2) -@test f1.bc() == 1 -@test f2.bc() == 2 - -# Testing remake for no recompile -u0 = [0;2.] -tspan = (0.0,6.3) -prob = ODEProblem{true,false}((du,u,p,t) -> 2u,u0,tspan) - -# Function wrapper makes a new reference, it doesn't make it type instable -@test_broken remake(prob) == prob -@test remake(prob; u0 = [1;2]).u0 == [1;2] -@test remake(prob; p = (1,2)).p == (1,2) diff --git a/test/runtests.jl b/test/runtests.jl index 58e230077..73d361f1d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,5 +8,4 @@ const is_APPVEYOR = ( Sys.iswindows() && haskey(ENV,"APPVEYOR") ) @time begin @time @safetestset "Existence functions" begin include("existence_functions.jl") end @time @safetestset "Integrator interface" begin include("integrator_tests.jl") end -@time @safetestset "Remake tests" begin include("remake_tests.jl") end end