Skip to content

Read a number followed by j or J like 2i - #323

Open
peterbjohnson wants to merge 3 commits into
mainfrom
fix/number-followed-by-j
Open

peterbjohnson wants to merge 3 commits into
mainfrom
fix/number-followed-by-j

Conversation

@peterbjohnson

Copy link
Copy Markdown
Member

Fixes #321.

Without complexNumbers, a vector response 3i+2j+6k was marked wrong against 3*i+2*j+6*k. Python's tokenizer reads 2j as an imaginary literal, so it became 2*I, and input symbols didn't help.

The fix is in the package: lambda-feedback/lambda-feedback-packages#33. A number followed by j/J now reads like 2i:

  • loose syntax: 2*j
  • strict syntax: a syntax error
  • with complexNumbers: unchanged

This PR

  • app/requirements.txt: temporarily pins all four packages to commit 7006a92 of that PR. Repin to the release tag (e.g. v0.3.0-rc.6) before merging, which is why this is a draft.
  • Tests: 41 new cases in symbolic_evaluation_test.py and symbolic_preview_test.py. They come from the earlier app-level patch, which was dropped, with these changes:
  • app/docs/user.md: a note on 2j under complexNumbers, and a new example "Entering vectors as 3i+2j+6k".

Checks

  • Fresh install from requirements.txt: 1281 passed, 2 skipped, 1 xfailed. On main it was 1240 passed.
  • mypy app: clean. No new lines over 127 characters.

🤖 Generated with Claude Code

peterbjohnson and others added 3 commits November 27, 2026 21:53
Without complexNumbers, `3i+2j+6k` parsed as `3*i + 2*I + 6*k`, because
Python reads `2j` as an imaginary literal. The fix is in
lambdafeedback-expression-parsing (lambda-feedback-packages#33): `2j` is
now `2*j`, a syntax error with strict syntax (like `2i`), and unchanged
with complexNumbers.

Pins the packages to that branch's commit until it is released, adds
tests (from the dropped app-level patch, adjusted: no `1e3j` case, which
depends on #322; preview `sympy` keeps the response as typed; strict
syntax cases) and documents `2j` under complexNumbers and vectors.

Fixes #321.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@peterbjohnson
peterbjohnson marked this pull request as ready for review November 27, 2026 22:31

This branch has not been deployed

No deployments
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.

Bug: Number followed by j or J parses as a Python complex literal

1 participant