Add SciMLBaseExt#652
Conversation
Fixes error when passing an AbstractInterpolation as a parameter to a SciML problem constructor (DifferentialEquations.jl, NonlinearSolve.jl, Optimization.jl, etc..) where the fact that AbstractInterpolation <: AbstractArray would cause the parameter type warning to attempt to iterate over the AbstractInterpolation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #652 +/- ##
==========================================
+ Coverage 87.83% 87.84% +0.01%
==========================================
Files 29 30 +1
Lines 1907 1909 +2
==========================================
+ Hits 1675 1677 +2
Misses 232 232 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I'm a little suprised to see this as https://github.com/SciML/DataInterpolations.jl is usually the intepolations package to use with the SciML ecosystem. I'm a little confused how "not warning" elides an error. |
There was a problem hiding this comment.
Pull request overview
Adds a SciMLBase package extension so SciMLBase’s parameter-type warning logic can safely handle Interpolations.AbstractInterpolation{<:AbstractArray} parameters (e.g., in DifferentialEquations/Optimization problem constructors) without triggering BoundsErrors from iterating the interpolation as an AbstractArray.
Changes:
- Add
InterpolationsSciMLBaseExtextension to overrideSciMLBase.should_warn_paramtypeforAbstractInterpolation{<:AbstractArray}. - Add SciMLBase-focused tests and wire them into the test suite.
- Register SciMLBase as a weak dep + extension + test dependency in
Project.toml.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
ext/InterpolationsSciMLBaseExt.jl |
Adds SciMLBase extension method for should_warn_paramtype on interpolations of arrays. |
test/scimlbase.jl |
Adds tests for SciMLBase should_warn_paramtype behavior with interpolations. |
test/runtests.jl |
Includes the new SciMLBase test file in the test run. |
Project.toml |
Adds SciMLBase as a weakdep/extension and includes it in test extras/targets + compat. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
DataInterpolations.jl wasn't known to me. I could just switch.
|
- simply forward the coefficients of the interpolation to the SciML warning, also mitigates discrepancy between eltype(i::Interpolation) and eltype(coefficients(i::Interpolation)) - Test both BSpline & Gridded interpolations with abstract/concrete coefficients
|
Unless there are any other suggestions from the maintainers (or the robot, on their behalf), I am satisfied with this. |
|
This is reasonable. Though generally the rule is to put the extension where the non-public API lives. IIUC, this is using public API of Interpolations.jl and non-public API of SciMLBase, so the fitting place would likely be SciMLBase. But if you want to maintain it here, that would be fine, it's just not guaranteed to continue to work here. |
This change uses non-public API of both packages. I guess it could work with |
|
Yeah, looking at what this PR is doing, I would definitely prefer for it to live in SciMLBase |
Fixes a possible BoundsError when passing an AbstractInterpolation as a parameter to a SciML problem constructor (DifferentialEquations.jl, NonlinearSolve.jl, Optimization.jl, etc..) where the fact that
AbstractInterpolation{<:AbstractArray} <: AbstractArray{<:AbstractArray}would cause the parameter type warning check to iterate over the AbstractInterpolation.Changes:
Example Error Details:
Details