Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
contents: read

jobs:
test:
Ariadne:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.version == 'nightly' }}
Expand Down Expand Up @@ -42,3 +42,27 @@ jobs:
- uses: codecov/codecov-action@v1
with:
file: lcov.info
Theseus:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.version == 'nightly' }}
strategy:
fail-fast: false
matrix:
version:
- "1.10"
- "1.11"
# - "nightly"
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v2
10 changes: 10 additions & 0 deletions libs/Theseus/test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[deps]
Ariadne = "0be81120-40bf-4f8b-adf0-26103efb66f1"
ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Theseus = "7f538e44-2768-4ef2-af90-2110c0378286"
TrixiTest = "0a316866-cbd0-4425-8bcb-08103b2c1f26"

[sources]
Ariadne = {path = "../../.."}
Theseus = {path = ".."}
4 changes: 4 additions & 0 deletions libs/Theseus/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using Theseus
using ParallelTestRunner

runtests(Theseus, ARGS)
9 changes: 5 additions & 4 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Ariadne = "0be81120-40bf-4f8b-adf0-26103efb66f1"
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Ariadne = "0be81120-40bf-4f8b-adf0-26103efb66f1"
ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources.Ariadne]
path = ".."
[sources]
Ariadne = {path = ".."}
70 changes: 2 additions & 68 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,70 +1,4 @@
using Test
using Ariadne
using ParallelTestRunner

function F!(res, x, _)
res[1] = x[1]^2 + x[2]^2 - 2
return res[2] = exp(x[1] - 1) + x[2]^2 - 2
end

function F(x, p)
res = similar(x)
F!(res, x, p)
return res
end

let x₀ = [2.0, 0.5]
x, stats = newton_krylov!(F!, x₀)
@test stats.solved
end

let x₀ = [3.0, 5.0]
x, stats = newton_krylov(F, x₀)
@test stats.solved
end

import Ariadne: JacobianOperator, BatchedJacobianOperator
using Enzyme, LinearAlgebra

@testset "Jacobian" begin
J_Enz = jacobian(Forward, x -> F(x, nothing), [3.0, 5.0]) |> only
J = JacobianOperator(F!, zeros(2), [3.0, 5.0], nothing)

@test size(J) == (2, 2)
@test length(J) == 4
@test eltype(J) == Float64

out = [NaN, NaN]
mul!(out, J, [1.0, 0.0])
@test out == [6.0, 7.38905609893065]

out = [NaN, NaN]
mul!(out, transpose(J), [1.0, 0.0])
@test out == [6.0, 10.0]

J_NK = collect(J)

@test J_NK == J_Enz

v = rand(2)
out = similar(v)
mul!(out, J, v)

@test out ≈ J_Enz * v

@test collect(transpose(J)) == transpose(collect(J))

# Batched
if VERSION >= v"1.11.0"
J = BatchedJacobianOperator{2}(F!, zeros(2), [3.0, 5.0], nothing)

V = [1.0 0.0; 0.0 1.0]
Out = similar(V)
mul!(Out, J, V)

@test Out == J_Enz

mul!(Out, transpose(J), V)
@test Out == J_Enz'
# @test Out == collect(transpose(J))
end
end
runtests(Ariadne, ARGS)
70 changes: 70 additions & 0 deletions test/tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Test
using Ariadne

function F!(res, x, _)
res[1] = x[1]^2 + x[2]^2 - 2
return res[2] = exp(x[1] - 1) + x[2]^2 - 2
end

function F(x, p)
res = similar(x)
F!(res, x, p)
return res
end

let x₀ = [2.0, 0.5]
x, stats = newton_krylov!(F!, x₀)
@test stats.solved
end

let x₀ = [3.0, 5.0]
x, stats = newton_krylov(F, x₀)
@test stats.solved
end

import Ariadne: JacobianOperator, BatchedJacobianOperator
using Enzyme, LinearAlgebra

@testset "Jacobian" begin
J_Enz = jacobian(Forward, x -> F(x, nothing), [3.0, 5.0]) |> only
J = JacobianOperator(F!, zeros(2), [3.0, 5.0], nothing)

@test size(J) == (2, 2)
@test length(J) == 4
@test eltype(J) == Float64

out = [NaN, NaN]
mul!(out, J, [1.0, 0.0])
@test out == [6.0, 7.38905609893065]

out = [NaN, NaN]
mul!(out, transpose(J), [1.0, 0.0])
@test out == [6.0, 10.0]

J_NK = collect(J)

@test J_NK == J_Enz

v = rand(2)
out = similar(v)
mul!(out, J, v)

@test out ≈ J_Enz * v

@test collect(transpose(J)) == transpose(collect(J))

# Batched
if VERSION >= v"1.11.0"
J = BatchedJacobianOperator{2}(F!, zeros(2), [3.0, 5.0], nothing)

V = [1.0 0.0; 0.0 1.0]
Out = similar(V)
mul!(Out, J, V)

@test Out == J_Enz

mul!(Out, transpose(J), V)
@test Out == J_Enz'
# @test Out == collect(transpose(J))
end
end
Loading