Conversation
Codecov Report
@@ Coverage Diff @@
## master #468 +/- ##
==========================================
- Coverage 85.11% 76.42% -8.70%
==========================================
Files 26 26
Lines 1747 1421 -326
==========================================
- Hits 1487 1086 -401
- Misses 260 335 +75
Continue to review full report at Codecov.
|
|
Hm... Julia 1.7 has a regression in type inference related to |
|
I am still not convinced that we are honoring the user's intentions here. In your example we have two unique knots: julia> A = [1.0, 1.0, 1.0, nextfloat(1.0), nextfloat(1.0)]
5-element Vector{Float64}:
1.0
1.0
1.0
1.0000000000000002
1.0000000000000002
julia> B = deduplicate_knots!(copy(A))
5-element Vector{Float64}:
1.0
1.0000000000000002
1.0000000000000004
1.0000000000000007
1.0000000000000009
julia> V = [1,2,3,4,5]
5-element Vector{Int64}:
1
2
3
4
5
itp = interpolate((B,), V, Gridded(Linear()))
julia> collect(zip(A, itp.(A)))
5-element Vector{Tuple{Float64, Float64}}:
(1.0, 1.0)
(1.0, 1.0)
(1.0, 1.0)
(1.0000000000000002, 2.0)
(1.0000000000000002, 2.0)Above My expectation is that We may thus need a two argument version of The behavior of julia> V = [1,4,5]
3-element Vector{Int64}:
1
4
5
julia> B = [1.0, nextfloat(1.0), nextfloat(nextfloat(1.0))]
3-element Vector{Float64}:
1.0
1.0000000000000002
1.0000000000000004
julia> itp = interpolate((B,), V, Gridded(Linear()))
3-element interpolate((::Vector{Float64},), ::Vector{Int64}, Gridded(Linear())) with element type Float64:
1.0
4.0
5.0
julia> itp.(A)
3-element Vector{Float64}:
1.0
4.0
5.0
julia> collect(zip(A, itp.(A)))
3-element Vector{Tuple{Float64, Float64}}:
(1.0, 1.0)
(1.0000000000000002, 4.0)
(1.0000000000000004, 5.0)
|
|
Right, my solution is not perfect (though it's fine for my use case). Actually I'm not sure what the best solution would be. Consider knots |
|
In general, I think the user should probably fix the data themselves. I consider |
|
As for Interpolations.jl/src/Interpolations.jl Lines 150 to 161 in eefe448 with: itptype(::Type{<:AbstractInterpolation{T,N,IT}}) where {T,N,IT<:DimSpec{InterpolationType}} = IT
itptype(itp::AbstractInterpolation) = itptype(typeof(itp))
ndims(::Type{<:AbstractInterpolation{T,N,<:DimSpec{InterpolationType}}}) where {T,N} = N
ndims(itp::AbstractInterpolation) = ndims(typeof(itp))
eltype(::Type{<:AbstractInterpolation{T,N,<:DimSpec{InterpolationType}}}) where {T,N} = T
eltype(itp::AbstractInterpolation) = eltype(typeof(itp))I delete |
|
@N5N3, I'm unclear how this is related. Could you open a new issue or PR? |
|
To move this PR forward, could we implement this behavior as an keyword option? I think this may be useful to others, but I do not think it should be the default behavior. |
|
This PR is a bit stuck on unrelated Julia 1.7 failures so I was planning to go back to it once that is solved in some way. I'm also not quite sure at the moment how exactly this should work. |
|
Let me worry about 1.7. |
|
I ended up going with a warning: julia> Interpolations.deduplicate_knots!([1.0, 1.0, 1.0, nextfloat(1.0), nextfloat(1.0)])
┌ Warning: Successive repeated knots detected. Consider using `move_knots` keyword to Interpolations.deduplicate_knots!
│ last_knot = 1.0
│ knots[i - 1] = 1.0000000000000004
│ knots[i] = 1.0000000000000002
└ @ Interpolations C:\Users\kittisopikulm\.julia\dev\Interpolations\src\gridded\gridded.jl:120
5-element Vector{Float64}:
1.0
1.0000000000000002
1.0000000000000004
1.0000000000000007
1.0000000000000009 |
|
Fix #467 |
|
Thanks for finishing it! I was still considering adding the node removal feature here but I was busy with other work. |
This small PR ensures that more pathological cases of duplicated knots (for example
[1.0, 1.0, 1.0, nextfloat(1.0), nextfloat(1.0)]) are correctly handled.