Skip to content

Commit 4050a64

Browse files
committed
Fix ambiguities, might still need to fix Constant(::Periodic)
1 parent 88da352 commit 4050a64

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

src/Interpolations.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ struct InPlaceQ{GT<:Union{GridType,Nothing}} <: BoundaryCondition gt::GT end
109109
const Natural = Line
110110

111111
(::Type{BC})() where BC<:BoundaryCondition = BC(nothing)
112-
(::Type{BC})(::Type{GT}) where {GT <: GridType, BC<:BoundaryCondition} = BC{GT}(GT())
112+
# (::Type{BC})(::Type{GT}) where {GT <: GridType, BC<:BoundaryCondition} = BC{GT}(GT())
113+
for BC in (:Throw, :Flat, :Line, :Free, :Reflect, :InPlace)
114+
eval(quote
115+
$BC(::Type{GT}) where GT <: GridType = $BC{GT}(GT())
116+
$BC{GT}(::Type{GT}) where GT <: GridType = $BC{GT}(GT())
117+
end)
118+
end
113119
function Base.show(io::IO, bc::BoundaryCondition)
114120
print(io, nameof(typeof(bc)), '(')
115121
bc.gt === nothing || show(io, bc.gt)

src/b-splines/constant.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ struct Constant{T<:ConstantInterpType,BC<:Union{Throw{OnGrid},Periodic{OnCell}}}
3737
end
3838

3939
# Default to Nearest and Throw{OnGrid}
40-
Constant(args...) = Constant{Nearest}(args...)
40+
Constant() = Constant{Nearest}()
4141
Constant{T}() where {T<:ConstantInterpType} = Constant{T,Throw{OnGrid}}(Throw(OnGrid()))
4242
Constant{T}(bc::BC) where {T<:ConstantInterpType,BC<:BoundaryCondition} = Constant{T,BC}(bc)
43+
Constant(p::Periodic) where {T<:ConstantInterpType} = Constant{Nearest}(p)
4344
Constant{T}(::Periodic{Nothing}) where {T<:ConstantInterpType} = Constant{T,Periodic{OnCell}}(Periodic(OnCell()))
4445
Constant(::Type{T}) where T <: ConstantInterpType = Constant{T}()
4546

src/b-splines/cubic.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ end
55
(deg::Cubic)(gt::GridType) = Cubic(deg.bc(gt))
66
# Default constructor to match cubic_spline_interpolation
77
Cubic() = Cubic(Line(OnGrid()))
8+
Cubic{BC}(::Type{BC}) where BC <: BoundaryCondition = Cubic{BC}(BC())
9+
Cubic{BC}(::Type{BC2}) where {BC <: BoundaryCondition, BC2 <: BoundaryCondition} = throw(ArgumentError("Argument must match type parameter"))
810

911
"""
1012
Cubic(bc::BoundaryCondition)

src/b-splines/quadratic.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ struct Quadratic{BC<:BoundaryCondition} <: DegreeBC{2}
33
end
44
# Default constructor
55
Quadratic() = Quadratic(Line(OnGrid()))
6+
Quadratic{BC}(::Type{BC}) where BC <: BoundaryCondition = Quadratic{BC}(BC())
7+
Quadratic{BC}(::Type{BC2}) where {BC <: BoundaryCondition, BC2 <: BoundaryCondition} = throw(ArgumentError("Argument must match type parameter"))
68
(deg::Quadratic)(gt::GridType) = Quadratic(deg.bc(gt))
79

810

0 commit comments

Comments
 (0)