Skip to content
Open
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
8 changes: 5 additions & 3 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ on:
branches:
- main
paths-ignore:
- 'docs/**'
- "docs/**"
push:
branches:
- main
paths-ignore:
- 'docs/**'
- "docs/**"
schedule:
- cron: '59 12 * * 2'
- cron: "59 12 * * 2"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -26,6 +26,7 @@ jobs:
matrix:
group:
- Core
- Extensions
- QA
version:
- "1"
Expand All @@ -40,6 +41,7 @@ jobs:
version: "pre"
uses: "SciML/.github/.github/workflows/tests.yml@v1"
with:
group: "${{ matrix.group }}"
julia-version: "${{ matrix.version }}"
os: "${{ matrix.os }}"
secrets: "inherit"
7 changes: 4 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,25 @@ DataInterpolations = "8"
EllipsisNotation = "1.8.0"
ForwardDiff = "0"
KernelAbstractions = "0.9.34"
Pkg = "1"
PrecompileTools = "1.0"
Random = "1"
RecipesBase = "1.3.4"
SafeTestsets = "0.1"
SymbolicUtils = "4"
Symbolics = "7"
Test = "1"
TestItemRunner = "1"
julia = "1"

[extras]
DataInterpolations = "82cc6244-b520-54b8-b5a6-8a565e85f1d0"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"

[targets]
test = ["DataInterpolations", "ForwardDiff", "Pkg", "Random", "SafeTestsets", "Symbolics", "Test", "SymbolicUtils"]
test = ["DataInterpolations", "ForwardDiff", "Pkg", "Random", "Symbolics", "Test", "TestItemRunner", "SymbolicUtils"]
20 changes: 7 additions & 13 deletions src/interpolation_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,18 @@ function validate_size_u(
return @assert expected_size == size(u)[1:N_in] "Expected the size of the first N_in dimensions of u to be $expected_size based on the BSplineInterpolation properties."
end

function validate_cache(
::EmptyCache, ::NTuple{N_in, ID}, ::AbstractArray
) where {N_in, ID}
return nothing
end

function validate_cache(
nurbs_weights::NURBSWeights,
::NTuple{N_in, BSplineInterpolationDimension},
u::AbstractArray
) where {N_in}
function validate_cache(nurbs_weights::NURBSWeights, interp_dims, u::AbstractArray)
N_in = length(interp_dims)
size_expected = size(u)[1:N_in]
return @assert size(nurbs_weights.weights) == size_expected "The size of the weights array must match the length of the first N_in dimensions of u ($size_expected)."
end

validate_cache(cache::AbstractInterpolationCache, interp_dims, u::AbstractArray) = validate_cache(cache, first(interp_dims))
validate_cache(::EmptyCache, ::AbstractInterpolationDimension) = nothing

function validate_cache(
::gType, ::NTuple{N_in, ID}, ::AbstractArray
) where {gType, N_in, ID}
::gType, ::ID
) where {gType <: AbstractInterpolationCache, ID <: AbstractInterpolationDimension}
return @error("Interpolation dimension type $ID is not compatible with global cache type $gType.")
end

Expand Down
6 changes: 0 additions & 6 deletions test/qa/aqua.jl

This file was deleted.

8 changes: 4 additions & 4 deletions test/qa/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using SafeTestsets
using TestItemRunner

@safetestset "Aqua" include("aqua.jl")
@safetestset "ExplicitImports" include("explicit_imports.jl")
@safetestset "JET" include("jet.jl")
include("test_qa_aqua.jl")
include("test_qa_explicit_imports.jl")
include("test_qa_jet.jl")
5 changes: 5 additions & 0 deletions test/qa/test_qa_aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@testitem "Aqua" begin
using Aqua
using DataInterpolationsND
Aqua.test_all(DataInterpolationsND)
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using ExplicitImports
using DataInterpolationsND
using Test

@testset "ExplicitImports" begin
@testitem "ExplicitImports" begin
using ExplicitImports
using DataInterpolationsND
@test check_no_implicit_imports(DataInterpolationsND) === nothing
@test check_no_stale_explicit_imports(DataInterpolationsND) === nothing
end
12 changes: 6 additions & 6 deletions test/qa/jet.jl → test/qa/test_qa_jet.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using JET
using DataInterpolationsND
using Test

@testset "JET static analysis" begin
@testitem "JET static analysis" begin
using JET
using DataInterpolationsND
# Linear interpolation setup
t1 = [-3.14, 1.0, 3.0, 7.6, 12.8]
t2 = [-2.71, 1.41, 12.76, 50.2, 120.0]
Expand Down Expand Up @@ -118,7 +116,9 @@ using Test
end
end

@testset "JET type optimization" begin
@testitem "JET type optimization" begin
using JET
using DataInterpolationsND
# Linear interpolation setup
t1 = [-3.14, 1.0, 3.0, 7.6, 12.8]
t2 = [-2.71, 1.41, 12.76, 50.2, 120.0]
Expand Down
14 changes: 7 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using SafeTestsets, Pkg
using TestItemRunner, Pkg
const GROUP = get(ENV, "GROUP", "All")

function activate_gpu_env()
Expand All @@ -14,15 +14,15 @@ function activate_qa_env()
end

if GROUP == "All" || GROUP == "Core"
@safetestset "Interpolations" include("test_interpolations.jl")
@safetestset "Derivatives" include("test_derivatives.jl")
@safetestset "DataInterpolations" include("test_datainterpolations_comparison.jl")
@safetestset "Interface" include("test_interface.jl")
core_files = ("test_interpolations.jl", "test_derivatives.jl", "test_datainterpolations_comparison.jl", "test_interface.jl")
@run_package_tests filter = ti -> any(endswith(ti.filename, file) for file in core_files)

elseif GROUP == "Extensions"
@safetestset "Symbolics Extension" include("test_symbolics_ext.jl")
extension_files = ("test_symbolics_ext.jl",)
@run_package_tests filter = ti -> any(endswith(ti.filename, file) for file in extension_files)
elseif GROUP == "QA"
activate_qa_env()
include("qa/runtests.jl")
@run_package_tests filter = ti -> contains(ti.filename, r"test_qa_")
elseif GROUP == "GPU"
activate_gpu_env()
# TODO: Add GPU tests
Expand Down
115 changes: 58 additions & 57 deletions test/test_datainterpolations_comparison.jl
Original file line number Diff line number Diff line change
@@ -1,75 +1,76 @@
using DataInterpolationsND
using DataInterpolations
@testitem "DataInterpolations comparison" begin
using DataInterpolations

isapprox_or_nan(v1, v2) = (v1 ≈ v2) || (all(isnan, v1) && all(isnan, v2))
isapprox_or_nan(v1, v2) = (v1 ≈ v2) || (all(isnan, v1) && all(isnan, v2))

function interpolation_comparison(
itp_dim_type::Type{<:DataInterpolationsND.AbstractInterpolationDimension},
itp_type::Type{<:DataInterpolations.AbstractInterpolation}
)
t = [0.0, 0.2, 0.5, 0.7, 0.9, 1.1]
u = [1.5, -5.3, 0.5, 3.3, 3.6, 1.0]
function interpolation_comparison(
itp_dim_type::Type{<:DataInterpolationsND.AbstractInterpolationDimension},
itp_type::Type{<:DataInterpolations.AbstractInterpolation}
)
t = [0.0, 0.2, 0.5, 0.7, 0.9, 1.1]
u = [1.5, -5.3, 0.5, 3.3, 3.6, 1.0]

n = length(t)
n = length(t)

itp_DI = itp_type(u, t)
itp_NDI = NDInterpolation(u, itp_dim_type(t))
itp_DI = itp_type(u, t)
itp_NDI = NDInterpolation(u, itp_dim_type(t))

# Interior non data points
for i in 1:(n - 1)
t_eval = range(t[i], t[i + 1]; length = 25)[2:24]
# Interior non data points
for i in 1:(n - 1)
t_eval = range(t[i], t[i + 1]; length = 25)[2:24]
@test itp_DI(t_eval) ≈ itp_NDI.(t_eval)
end

# Interior data points
t_eval = view(t, 2:(n - 1))
@test itp_DI(t_eval) ≈ itp_NDI.(t_eval)

# Boundary points
t_eval = [first(t), last(t)]
return @test itp_DI(t_eval) ≈ itp_NDI.(t_eval)
end

# Interior data points
t_eval = view(t, 2:(n - 1))
@test itp_DI(t_eval) ≈ itp_NDI.(t_eval)
function interpolation_derivative_comparison(
itp_dim_type::Type{<:DataInterpolationsND.AbstractInterpolationDimension},
itp_type::Type{<:DataInterpolations.AbstractInterpolation}
)
t = [0.0, 0.2, 0.5, 0.7, 0.9, 1.1]
u = [1.5, -5.3, 0.5, 3.3, 3.6, 1.0]

# Boundary points
t_eval = [first(t), last(t)]
return @test itp_DI(t_eval) ≈ itp_NDI.(t_eval)
end
n = length(t)

function interpolation_derivative_comparison(
itp_dim_type::Type{<:DataInterpolationsND.AbstractInterpolationDimension},
itp_type::Type{<:DataInterpolations.AbstractInterpolation}
)
t = [0.0, 0.2, 0.5, 0.7, 0.9, 1.1]
u = [1.5, -5.3, 0.5, 3.3, 3.6, 1.0]
itp_DI = itp_type(u, t)
itp_NDI = NDInterpolation(u, itp_dim_type(t))

n = length(t)
# Interior non data points
for i in 1:(n - 1)
t_eval = range(t[i], t[i + 1]; length = 25)[2:24]
@test DataInterpolations.derivative.(Ref(itp_DI), t_eval) ≈
itp_NDI.(t_eval; derivative_orders = (1,))
end

itp_DI = itp_type(u, t)
itp_NDI = NDInterpolation(u, itp_dim_type(t))
# Interior data points
t_eval = view(t, 2:(n - 1))
@test isapprox_or_nan(
DataInterpolations.derivative.(Ref(itp_DI), t_eval),
itp_NDI.(t_eval; derivative_orders = (1,))
)

# Interior non data points
for i in 1:(n - 1)
t_eval = range(t[i], t[i + 1]; length = 25)[2:24]
@test DataInterpolations.derivative.(Ref(itp_DI), t_eval)
# Boundary points
t_eval = [first(t), last(t)]
return @test isapprox_or_nan(
DataInterpolations.derivative.(Ref(itp_DI), t_eval),
itp_NDI.(t_eval; derivative_orders = (1,))
)
end

# Interior data points
t_eval = view(t, 2:(n - 1))
@test isapprox_or_nan(
DataInterpolations.derivative.(Ref(itp_DI), t_eval),
itp_NDI.(t_eval; derivative_orders = (1,))
)

# Boundary points
t_eval = [first(t), last(t)]
return @test isapprox_or_nan(
DataInterpolations.derivative.(Ref(itp_DI), t_eval),
itp_NDI.(t_eval; derivative_orders = (1,))
)
end

for (itp_dim_type, itp_type) in (
(LinearInterpolationDimension, LinearInterpolation),
(ConstantInterpolationDimension, ConstantInterpolation),
)
@testset "$itp_type" begin
interpolation_comparison(itp_dim_type, itp_type)
interpolation_derivative_comparison(itp_dim_type, itp_type)
for (itp_dim_type, itp_type) in (
(LinearInterpolationDimension, LinearInterpolation),
(ConstantInterpolationDimension, ConstantInterpolation),
)
@testset "$itp_type" begin
interpolation_comparison(itp_dim_type, itp_type)
interpolation_derivative_comparison(itp_dim_type, itp_type)
end
end
end
Loading
Loading