Skip to content

Commit

Permalink
Fix possible stack-overflow within broadcast. (#510)
Browse files Browse the repository at this point in the history
* Fix possible stack-overflow within broadcast.

* Bump

* Fix test on 1.0
  • Loading branch information
N5N3 authored Aug 10, 2022
1 parent 62bfe77 commit e6d076a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Interpolations"
uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
version = "0.14.3"
version = "0.14.4"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
1 change: 1 addition & 0 deletions src/gpu_support.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ end
This function returns the type of the root cofficients array of an `AbstractInterpolation`.
Some array wrappers, like `OffsetArray`, should be skipped.
"""
root_storage_type(::Type{T}) where {T<:AbstractInterpolation} = Array{eltype(T),ndims(T)} # fallback to `Array` by default.
root_storage_type(::Type{T}) where {T<:Extrapolation} = root_storage_type(fieldtype(T, 1))
root_storage_type(::Type{T}) where {T<:ScaledInterpolation} = root_storage_type(fieldtype(T, 1))
root_storage_type(::Type{T}) where {T<:BSplineInterpolation} = root_storage_type(fieldtype(T, 1))
Expand Down
10 changes: 10 additions & 0 deletions test/issues/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,14 @@ using Interpolations, Test, ForwardDiff
@test_throws ErrorException Interpolations.symsize(Val(2))
@test_throws ErrorException Interpolations.symsize(Val(33))
end
@testset "issue 509" begin
@eval struct CPUITP{T,N} <: AbstractInterpolation{T,N,NTuple{N,NoInterp}} end
@test Broadcast.BroadcastStyle(CPUITP{Int,2}) == Broadcast.BroadcastStyle(Matrix{Int})
# example in #509
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]
y = sort(randn(length(percentile_values)))
itp_cdf = extrapolate(interpolate(y, percentile_values, SteffenMonotonicInterpolation()), Flat())
t = -3.0:0.01:3.0
@test itp_cdf.(t) isa Vector{Float64}
end
end

2 comments on commit e6d076a

@mkitti
Copy link
Collaborator

@mkitti mkitti commented on e6d076a Aug 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/66013

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.14.4 -m "<description of version>" e6d076a128f7ba1daab214e650cbd81801cb05a0
git push origin v0.14.4

Please sign in to comment.