Skip to content

Improve type-inference in adding operators - #708

Merged
jishnub merged 1 commit into
JuliaApproximation:masterfrom
jishnub:plusoperator-inference
Oct 26, 2026
Merged

jishnub merged 1 commit into
JuliaApproximation:masterfrom
jishnub:plusoperator-inference

Conversation

@jishnub

@jishnub jishnub commented Oct 25, 2026

Copy link
Copy Markdown
Member

Space promotion in promoteplus produces operator types that depend on the values of the spaces. For example, Conversion(Chebyshev(), Ultraspherical(λ)) is a ConcreteConversion for λ = 1 but a ConversionWrapper for λ = 2. That union used to reach the PlusOperator constructor, so + inferred as a 3-way union.

Changes:

  • promoteplus now keeps the concrete operator type only if promotion preserves it, and otherwise stores the operators as Operator{T}. The bandwidths are computed from the promoted tuple before the operators are converted to Operator{T}, so the bandwidth type parameters still infer.
  • promotedomainspace/promoterangespace on a Conversion return the operator unchanged if the space already matches, instead of rebuilding it.

Inferred return type of +, with C1 = Conversion(Chebyshev(), Ultraspherical(1)), C2 = Conversion(Chebyshev(), Ultraspherical(2)), D = Derivative(Chebyshev()):

Sum Before After
C1 + C2 3-way union concrete
C1 + C1, D + D 3-way union 2-way union
D + C1, Multiplication + D — concrete

Tradeoff: 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

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

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.47%. Comparing base (023b1a4) to head (e4bab05).
⚠️ Report is 57 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jishnub
jishnub merged commit 3d0f2fd into JuliaApproximation:master Oct 26, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant