Skip to content

Parse exponent-form numbers with extreme mantissas - #6233

Merged
rtibbles merged 1 commit into
learningequality:unstablefrom
rtibblesbot:issue-6228-f5c20f
Oct 2, 2026
Merged

rtibbles merged 1 commit into
learningequality:unstablefrom
rtibblesbot:issue-6228-f5c20f

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

extract_value returned None for exponent-form numbers whose mantissa repr uses exponent notation (0.00001e5, 12345678901234567e2), dropping those answers in _process_input_answers.

  • parse_exponent calls float() on the {mantissa}e{exp} string instead of eval on a string built from str(float).
  • No number_parser.js exists here, so there is no JS side.

Closes #6228

References

Reviewer guidance

AI usage

Implemented with Claude Code using TDD; new rows were run red against the old parser first. I reviewed the diff and ran test_parser.py.

🤖 Generated with Claude Code

Committed separately: no commit on this branch introduced the lines these changes touch, so they are a new commit rather than folded into the work they amend:

  • contentcuration/contentcuration/utils/parser.py

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Ran pre-flight CI checks (lint, format, tests) and verified all pass
  • Rebased onto the target branch and resolved any conflicts
  • Reorganized commit history into clean, logical commits
  • Audited the diff to ensure only issue-relevant files are changed
  • Built PR body from the repository's PR template with evidence blocks
@rtibblesbot

🟡 Waiting for feedback

Last updated: 2026-09-30 20:20 UTC

@rtibblesbot
rtibblesbot marked this pull request as ready for review September 30, 2026 17:24
@rtibblesbot
rtibblesbot requested review from a team and rtibbles September 30, 2026 17:24
@rtibblesbot
rtibblesbot force-pushed the issue-6228-f5c20f branch 2 times, most recently from 5ea4d64 to 2506386 Compare September 30, 2026 17:40

@rtibbles rtibbles left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question about conflicting updates.

(r"0\.0025", 0.0025),
(r"-4\.5%", -0.045),
(r"2\.3e10", 2.3e10),
("0.00001e5", 1.0),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels redundant with this? #6209

Once the above is merged, will we even need this parser any more?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not redundant: #6209 doesn't replace utils/parser.py. Its new code imports extract_value from it (searched the #6209 diff: 1 import, 1 call). Non-test callers on this branch: perseus.py:78 and parser.py itself (parse_exponent, percent parsing) — 3 places, all use the fixed parse_exponent. So extract_value stays after #6209 and these rows still test it. No changes made.

@rtibbles rtibbles self-assigned this Sep 30, 2026
Build the number with float() on the assembled string instead of eval on
str(float), so mantissas beyond double range parse.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@rtibbles
rtibbles merged commit f9ba51f into learningequality:unstable Oct 2, 2026
13 checks passed
@rtibblesbot
rtibblesbot deleted the issue-6228-f5c20f branch October 2, 2026 16:18
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.

Numeric answers with a very small or very large mantissa and an exponent are not parsed by extract_value

2 participants