Skip to content

expression-parsing: read sum(expr) without limits as an unevaluated sum - #2

Merged
m-messer merged 2 commits into
mainfrom
fix/unevaluated-sum
Oct 16, 2026
Merged

m-messer merged 2 commits into
mainfrom
fix/unevaluated-sum

Conversation

@m-messer

Copy link
Copy Markdown
Member

Fixes a regression found in the compareExpressions refactor sweep. With elementary_functions on, sum(...) with no limits was rewritten to SymPy's summation, which needs limits. Every submission to an affected question then got an HTTP 500, correct answers included.

Changes

  • One-argument sum(expr) now parses to UNEVALUATED_SUM(expr), an undefined function sum. Two sums are equal when their summands simplify equal. Nothing is factored out, because the index is unknown.
  • sum(f, (k, a, b)) and summation(...) still evaluate.
  • An applied sum(...) is a sum even when the task defines sum as a symbol code or alias. A bare sum stays the task's symbol (ALWAYS_FUNCTIONS in symbol_tables.py).
  • sympy_to_latex prints it as \sum{\left(… \right)}.
  • CHANGELOG entry under 0.3.0 Fixed.

Behaviour change: old cE only graded these questions because, by accident, it read sum as a plain symbol. Report case 3e65804e now grades incorrect, because its reference answer has sum(1/(2k+1)) * sin(...), with sin outside the sum. That reference answer needs fixing.

Testing: new TestSumWithoutLimits in tests/test_regressions.py. The expression_parsing, criteria and units suites pass, and ruff and mypy are clean. I also ran the report's repro cases through the cE refactor branch with this package: no 500s.

🤖 Generated with Claude Code

m-messer and others added 2 commits October 14, 2026 09:32
…s, refine LaTeX handling, enhance symbol alias logic, and add regression tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@m-messer
m-messer merged commit 395a812 into main Oct 16, 2026
8 checks passed
@m-messer
m-messer deleted the fix/unevaluated-sum branch October 16, 2026 08:31
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