Skip to content

Commit e81a025

Browse files
authored
Merge branch 'master' into compathelper/new_version/2021-08-04-00-16-45-998-1513176018
2 parents 423d703 + 940043f commit e81a025

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ WoodburyMatrices = "efce3f68-66dc-5838-9240-27a6d6f5f9b6"
1717

1818
[compat]
1919
AxisAlgorithms = "0.3, 1"
20-
ChainRulesCore = "0.10, 1.3"
20+
ChainRulesCore = "0.10, 1.0, 1.2, 1.3"
2121
OffsetArrays = "0.10, 0.11, 1.0.1"
2222
Ratios = "0.3, 0.4"
2323
Requires = "1.1"

src/Interpolations.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ maybe_clamp(itp, xs) = maybe_clamp(BoundsCheckStyle(itp), itp, xs)
470470
maybe_clamp(::NeedsCheck, itp, xs) = map(clamp, xs, lbounds(itp), ubounds(itp))
471471
maybe_clamp(::CheckWillPass, itp, xs) = xs
472472

473+
Base.hash(x::AbstractInterpolation, h::UInt = zero(UInt)) = Base.hash_uint(3h - objectid(x))
474+
Base.hash(x::AbstractExtrapolation, h::UInt = zero(UInt)) = Base.hash_uint(3h - objectid(x))
475+
473476
include("nointerp/nointerp.jl")
474477
include("b-splines/b-splines.jl")
475478
include("gridded/gridded.jl")

test/core.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,23 @@ end
5151
@test wi/2 === Interpolations.WeightedArbIndex((2, -1), (0.1, 0.4))
5252
@test Interpolations.indextuple(wi) == (2, -1)
5353
end
54+
55+
@testset "Hash" begin
56+
# Issue 339: Base.hash accesses out-of-bound indexes due to AbstractArray interface
57+
# Relevant to Distributed computing
58+
xr = collect(0.0:1.0:5.0)
59+
yr = collect(1.0:1.0:6.0)
60+
itp = interpolate((xr,),yr,Gridded(Linear()))
61+
# using Distributed
62+
# addprocs(2)
63+
# @everywhere begin
64+
# using Interpolations
65+
# callitp(itp, x) = itp(x)
66+
# end
67+
# r = remotecall(callitp, 2, itp, 1.2)
68+
# fetch(r) # 2.2
69+
@test hash(itp) != 0
70+
etp = LinearInterpolation([2, 3], [4, 5])
71+
@test hash(etp.itp) != 0
72+
@test hash(etp) != 0
73+
end

0 commit comments

Comments
 (0)