Test allocations#466
Merged
Merged
Conversation
The `zero(one(eltype(u)) / 2)` in `smoothed_constant_interpolation_parameters` made this interpolation fail for array-valued interpolations because `one(::AbstractArray)` is not defined. I replaced this with `zero(first(u) / 2)` which should maintain the same type stability across the different branches of the function. Tests added verifying the new functionality.
It can be Int or Nothing, but bounds are checked during extrapolation so we can assume it returns an Int. This fixes a dynamic dispatch found by AllocCheck.jl.
Contributor
Author
|
Three CubicSpline tests there were marked as broken on Julia < 1.11 are now passing on LTS ( see https://github.com/SciML/DataInterpolations.jl/actions/runs/17439841023/job/49519664698?pr=466) so I've updated those as well. |
ChrisRackauckas
approved these changes
Sep 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Following #457, this PR adds more tests for allocation-free interpolation of
Vector{SVector}inputs. To my knowledge, all interpolators that work with vector-valued inputs now have these tests. That list isTwo minor code changes are included to support this work.
spline_coefficients!it is required to assert the return type offindfirst(x -> x > u, k)::Intto avoid a dynamic dispatch to-asfindfirstcan return anIntorNothing. The dynamic dispatch causes the allocation check via AllocCheck.jl to fail. It looks like bounds checks on the inputs are performed during the extrapolation step, so I think it is safe to assert this return type.smoothed_constant_interpolation_parametersdoes not work on array-valued inputs asone(::AbstractArray)is not defined. I think type stability can be maintained by replacingzero(one(eltype(u)) / 2)withzero(first(u) / 2), but this is maybe not optimal ifuhas elements of mixed type. I suppose it could bezero(u[idx] / 2), other suggestions welcome.Also some of CubicSpline
@inferredtests that are labeled broken are now passing for me locally (Julia 1.11) so I changed those. If they fail on CI we can troubleshoot further.