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
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[weakdeps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"

[extensions]
DimensionalDataCategoricalArraysExt = "CategoricalArrays"
DimensionalDataInterpolations = "Interpolations"
DimensionalDataMakie = "Makie"

[compat]
Expand All @@ -51,6 +53,7 @@ Extents = "0.1"
ImageFiltering = "0.7"
ImageTransformations = "0.10"
Interfaces = "0.3"
Interpolations = "0.15"
IntervalSets = "0.5, 0.6, 0.7"
InvertedIndices = "1"
IteratorInterfaceExtensions = "1"
Expand Down Expand Up @@ -85,6 +88,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ImageFiltering = "6a3955dd-da59-5b1f-98d4-e7296123deb5"
ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Expand All @@ -95,4 +99,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["Aqua", "ArrayInterface", "BenchmarkTools", "CategoricalArrays", "ColorTypes", "Combinatorics", "CoordinateTransformations", "DataFrames", "Distributions", "Documenter", "ImageFiltering", "ImageTransformations", "CairoMakie", "OffsetArrays", "Plots", "Random", "SafeTestsets", "StatsPlots", "Test", "Unitful"]
test = ["Aqua", "ArrayInterface", "BenchmarkTools", "CategoricalArrays", "ColorTypes", "Combinatorics", "CoordinateTransformations", "DataFrames", "Distributions", "Documenter", "ImageFiltering", "ImageTransformations", "Interpolations", "CairoMakie", "OffsetArrays", "Plots", "Random", "SafeTestsets", "StatsPlots", "Test", "Unitful"]
13 changes: 13 additions & 0 deletions ext/DimensionalDataInterpolations.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module DimensionalDataInterpolations

using DimensionalData, Interpolations

function Interpolations.linear_interpolation(A::AbstractDimArray; kw...)
linear_interpolation(DimensionalData.index(dims(A)), A; kw...)
end

function Interpolations.cubic_spline_interpolation(A::AbstractDimArray; kw...)
cubic_spline_interpolation(DimensionalData.index(dims(A)), A; kw...)
end

end
23 changes: 23 additions & 0 deletions test/interpolations.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using DimensionalData
using Interpolations

f((x1, x2)) = log(x1+x2)
a = f.(DimPoints((X(1:1:10), Y(1:1.5:20))))
b = f.(DimPoints((X(1:1:10), Y([1.0,3,7.5,10,15]))))
to = rand(X(2:.3:7), Y(2:.3:17))
# out = DimensionalData.interp(A; to)

itp_a = linear_interpolation(a)
itp_b = linear_interpolation(b)
itp_ex = linear_interpolation(a, extrapolation_bc=(Flat(), Linear()))

itp_a(7.5,7.5)
itp_b(7.5,7.5)
itp_ex(10,13)
itp_ex(11,13)
itp_ex(10,14)

itp_ca = cubic_spline_interpolation(a)
# itp_cb = cubic_spline_interpolation(b) #fails, as expected

itp_ca(10,10)