Fix type instability in interpolating_time_indices(::Clamp, …)#5732
Merged
Conversation
The clamped index tuples used literal `0` for the fractional time index
while the in-range tuple used the `Float64` value `ñ`, so the `ifelse`
result inferred as `Union{Tuple{Int,Int,Int}, Tuple{Float64,Int,Int}}`.
Use `zero(ñ)` so all branches share an element type, matching the
pattern already used in `find_time_index`. This also removes the
Reactant compile warning about `ifelse` promoting mixed element-types,
which fired for any Reactant-compiled model interpolating a
FieldTimeSeries (Clamp is the default time-indexing mode).
Closes #5731
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
simone-silvestri
approved these changes
Jun 27, 2026
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.
Summary
Fixes #5731.
interpolating_time_indices(::Clamp, times, t)built its clamped index tuples with a literal0for the fractional time index, while the in-range tuple used theFloat64valueñ:The
ifelseover these tuples then inferred asUnion{Tuple{Int,Int,Int}, Tuple{Float64,Int,Int}}— a type instability.This also produces a Reactant compile warning on every compile ("
ifelsewith different element-types in Reactant works by promoting the element-type to the common type"), since Reactant mapsifelseelement-wise over tuples. BecauseClamp()is the default time-indexing mode forFieldTimeSeries, this fired for essentially any Reactant-compiled model interpolating time series data.Fix
Replace the literal
0withzero(ñ)so all branches share an element type, matching the pattern already used in the siblingfind_time_indexfunction:🤖 Generated with Claude Code