Skip to content

Commit e3499a7

Browse files
authored
use an extension instead of Requires on 1.9 (#549)
1 parent e6265d9 commit e3499a7

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1616
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1717
WoodburyMatrices = "efce3f68-66dc-5838-9240-27a6d6f5f9b6"
1818

19+
[weakdeps]
20+
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
21+
22+
[extensions]
23+
InterpolationsUnitfulExt = "Unitful"
24+
1925
[compat]
2026
Adapt = "2, 3"
2127
AxisAlgorithms = "0.3, 1"
@@ -24,6 +30,7 @@ OffsetArrays = "0.10, 0.11, 1.0.1"
2430
Ratios = "0.3, 0.4"
2531
Requires = "1.1"
2632
StaticArrays = "0.12, 1"
33+
Unitful = "1"
2734
WoodburyMatrices = "0.4, 0.5"
2835
julia = "1.3"
2936

ext/InterpolationsUnitfulExt.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module InterpolationsUnitfulExt
2+
3+
if !isdefined(Base, :get_extension)
4+
import ..Unitful, ..Interpolations
5+
else
6+
import Unitful, Interpolations
7+
end
8+
9+
Interpolations.tweight(A::AbstractArray{T}) where T <: Unitful.Quantity = Interpolations.tweight(Unitful.ustrip(A))
10+
11+
end

src/Interpolations.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export
3838

3939
using LinearAlgebra, SparseArrays
4040
using StaticArrays, WoodburyMatrices, Ratios, AxisAlgorithms, OffsetArrays
41-
using ChainRulesCore, Requires
41+
using ChainRulesCore
4242

4343
using Base: @propagate_inbounds, HasEltype, EltypeUnknown, HasLength, IsInfinite,
4444
SizeUnknown, Indices
@@ -450,8 +450,14 @@ if VERSION >= v"1.6"
450450
include("gpu_support.jl")
451451
end
452452

453+
if !isdefined(Base, :get_extension)
454+
using Requires
455+
end
456+
457+
@static if !isdefined(Base, :get_extension)
453458
function __init__()
454-
@require Unitful="1986cc42-f94f-5a68-af5c-568840ba703d" include("requires/unitful.jl")
459+
@require Unitful="1986cc42-f94f-5a68-af5c-568840ba703d" include("../ext/InterpolationsUnitfulExt.jl")
460+
end
455461
end
456462

457463
end # module

src/requires/README.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/requires/unitful.jl

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)