Skip to content

Commit e6d076a

Browse files
authored
Fix possible stack-overflow within broadcast. (#510)
* Fix possible stack-overflow within broadcast. * Bump * Fix test on 1.0
1 parent 62bfe77 commit e6d076a

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Interpolations"
22
uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
3-
version = "0.14.3"
3+
version = "0.14.4"
44

55
[deps]
66
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/gpu_support.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ end
5656
This function returns the type of the root cofficients array of an `AbstractInterpolation`.
5757
Some array wrappers, like `OffsetArray`, should be skipped.
5858
"""
59+
root_storage_type(::Type{T}) where {T<:AbstractInterpolation} = Array{eltype(T),ndims(T)} # fallback to `Array` by default.
5960
root_storage_type(::Type{T}) where {T<:Extrapolation} = root_storage_type(fieldtype(T, 1))
6061
root_storage_type(::Type{T}) where {T<:ScaledInterpolation} = root_storage_type(fieldtype(T, 1))
6162
root_storage_type(::Type{T}) where {T<:BSplineInterpolation} = root_storage_type(fieldtype(T, 1))

test/issues/runtests.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,14 @@ using Interpolations, Test, ForwardDiff
167167
@test_throws ErrorException Interpolations.symsize(Val(2))
168168
@test_throws ErrorException Interpolations.symsize(Val(33))
169169
end
170+
@testset "issue 509" begin
171+
@eval struct CPUITP{T,N} <: AbstractInterpolation{T,N,NTuple{N,NoInterp}} end
172+
@test Broadcast.BroadcastStyle(CPUITP{Int,2}) == Broadcast.BroadcastStyle(Matrix{Int})
173+
# example in #509
174+
percentile_values = [0.0, 0.01, 0.1, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 91.0, 92.0, 93.0, 94.0, 95.0, 96.0, 97.0, 98.0, 99.0, 99.9, 99.99, 100.0]
175+
y = sort(randn(length(percentile_values)))
176+
itp_cdf = extrapolate(interpolate(y, percentile_values, SteffenMonotonicInterpolation()), Flat())
177+
t = -3.0:0.01:3.0
178+
@test itp_cdf.(t) isa Vector{Float64}
179+
end
170180
end

0 commit comments

Comments
 (0)