Repository navigation
Conversation
Importing nltk is slow, mostly because it imports scipy.stats. Every LMS worker pays that cost, and so does each codejail run that uses chemcalc. The grammar is now written in pyparsing, which chemcalc already used for tokenizing. Parse actions build the same trees as before, in a small Tree class that keeps nltk.tree.Tree's equality and ordering. The rendering and comparison code is unchanged. Parse actions take all three of pyparsing's arguments. With fewer, pyparsing works out the count on the first call, which isn't thread-safe and can leave an action raising TypeError from then on. Also drops scipy, which chem hasn't imported since 2013. openedx-platform stopped importing it in openedx/openedx-platform#39410. Behavior changes: * { or } in the input is a parse error. It used to raise ValueError. * Brackets nested more than 20 deep (MAX_NESTING) are a parse error. The old parser took about 245 levels, then raised RecursionError. Tests: * chemcalc_baseline.json records what chem 2.0.1, the last nltk release, returned for about 1,460 expressions and pairs. test_chemcalc_baseline checks the current code against it. * Four quirks that are probably bugs are kept so that grading doesn't change: charge-starting-with-1, space-inside-number, float-factors and zero-count-raises. Each has a test in test_chemcalc_quirks.py. Baseline entries that depend on one are tagged and checked separately. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
They were only there to build scipy from source. #169 drops scipy, and numpy installs from a wheel on Python 3.12, so nothing in the test run needs them any more. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## ormsbee/chemcalc-drop-nltk #170 +/- ##
===========================================================
Coverage 97.06% 97.06%
===========================================================
Files 4 4
Lines 307 307
Branches 62 62
===========================================================
Hits 298 298
Misses 4 4
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ormsbee
approved these changes
Nov 21, 2026
ormsbee
left a comment
Contributor
There was a problem hiding this comment.
I made a couple of changes on my pyparsing PR, so this won't rebase cleanly But ✔️ on the build commit.
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.
Stacked on #169. With scipy gone, the apt step that installed
libblas-dev,liblapack-devandgfortranto build it has nothing left to do, so this removes it.@ormsbee can you take a look? If you'd rather fold it into #169, feel free to cherry-pick the commit.