Repository navigation
Fix/sum preview - #261
Closed
m-messer wants to merge 3 commits into
Closed
Fix/sum preview#261m-messer wants to merge 3 commits into
m-messer wants to merge 3 commits into
Conversation
This was referenced Oct 24, 2026
Member
Author
|
Ported onto the refactor in #299. |
m-messer
added a commit
that referenced
this pull request
Oct 28, 2026
Pins all four packages to ed05cfe on lambda-feedback-packages' rc5-preview branch (v0.3.0-rc.4 plus #11, #12 and #13), so the ports of #261, #273/#277, #276 and #278 can be tested against them. To be replaced by the v0.3.0-rc.5 tag before merging. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
m-messer
added a commit
that referenced
this pull request
Oct 28, 2026
Ports the preview test from #261: with infsum written as \sum_{n=1}^{\infty}, infsum((-1)^n/n^2) previews with the summand inside the sum, not as a product with the sum inside the fraction. The fix is in lambda-feedback-packages#11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
m-messer
added a commit
that referenced
this pull request
Oct 28, 2026
m-messer
added a commit
that referenced
this pull request
Oct 28, 2026
Ports the preview test from #261: with infsum written as \sum_{n=1}^{\infty}, infsum((-1)^n/n^2) previews with the summand inside the sum, not as a product with the sum inside the fraction. The fix is in lambda-feedback-packages#11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem:
Custom symbols defined with big-operator LaTeX (e.g.
infsumwith\sum_{n=1}^{\infty}) were treated as plain SymPy Symbol objects. This meantinfsum((-1)^n / n^2)parsed as multiplication (Symbol("infsum") * ((-1)^n / n^2)), causing the sum symbol to appear in fraction numerators or with spurious\cdotmultiply dots in the preview. For example, from JF's course:infsum((-1)^n / n^2)rendered with the sum symbol inside the fraction numerator instead of wrapping the expressionpi^2/3 + infsum((-1)^n*cos(n*x)*(4/n^2)rendered with a \cdot immediately after the sum symbolSolution:
Detect prefix operator symbols automatically from their existing
latexdefinition: if a symbol's LaTeX starts with a big operator command (\sum, \int, \prod, \lim, \bigcup, \bigcap), create a SymPy Function subclass for it instead of a Symbol. No changes to teacher-facing configuration are required.A SymPy Function subclass is necessary because of how SymPy's parser handles callable objects in
local_dict. Wheninfsumis a Symbol, SymPy's auto-multiplication transformation convertsinfsum(x)intoSymbol("infsum") * x.By placing a Function subclass in
local_dictinstead, SymPy's parser treatsinfsum(x)as a genuine function applicationInfSum(x), the subclass carries a_latex()method that the SymPy printer calls when it encounters
InfSum(x), returning{symbol_latex} {arg_latex} directly.Changes:
app/utility/expression_utilities.py- added BIG_OPERATOR_PREFIXES constant; modifiedsympy_symbols()to create a dynamic Function subclass (with custom_latex()) for any symbol whose LaTeX begins with a big operator prefix, falling back to Symbol otherwise.app/preview_test.py- added test_sum_previewTo test please use the sandbox here