Repository navigation
Improve type-inference in adding operators - #708
Merged
jishnub merged 1 commit intoOct 26, 2026
Merged
Conversation
Retain the concrete operator type in PlusOperator only if space promotion
preserves it, and store the operators as Operator{T} otherwise, so that the
result is a small Union instead of a large one. Also avoid reconstructing a
Conversion in promotedomainspace/promoterangespace if the space already matches.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #708 +/- ##
==========================================
+ Coverage 75.20% 76.47% +1.27%
==========================================
Files 79 81 +2
Lines 8445 8761 +316
==========================================
+ Hits 6351 6700 +349
+ Misses 2094 2061 -33 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Space promotion in
promoteplusproduces operator types that depend on the values of the spaces. For example,Conversion(Chebyshev(), Ultraspherical(λ))is aConcreteConversionforλ = 1but aConversionWrapperforλ = 2. That union used to reach thePlusOperatorconstructor, so+inferred as a 3-way union.Changes:
promoteplusnow keeps the concrete operator type only if promotion preserves it, and otherwise stores the operators asOperator{T}. The bandwidths are computed from the promoted tuple before the operators are converted toOperator{T}, so the bandwidth type parameters still infer.promotedomainspace/promoterangespaceon aConversionreturn the operator unchanged if the space already matches, instead of rebuilding it.Inferred return type of
+, withC1 = Conversion(Chebyshev(), Ultraspherical(1)),C2 = Conversion(Chebyshev(), Ultraspherical(2)),D = Derivative(Chebyshev()):C1 + C2C1 + C1,D + DD + C1,Multiplication + DTradeoff: sums whose spaces genuinely need promotion now always store
Vector{Operator{T}}.The ApproxFunBase and ApproxFunOrthogonalPolynomials test suites pass locally against this branch. The PR adds no new inference test, because none of the spaces in ApproxFunBase reproduce this case.
🤖 Generated with Claude Code