compiles alone accepts unbalanced parens and stray letters, so isotope-eval now also reports a balanced column and breaks hand-test exact match down by category (equation, variables, robustness, bounds, bigop-lhs, long, ...). The new rows come from the stress-test failures in #2 and #4-#9. Baseline with the current model: hand exact 41.2%, compiles 99.0%. Refs #3
24 lines
785 B
Python
24 lines
785 B
Python
import collections
|
|
|
|
from isotope_typst.evaluate import balanced, read_jsonl
|
|
from isotope_typst.validate import compiles_many
|
|
|
|
|
|
def test_balanced():
|
|
assert balanced("frac(sin(x), x)")
|
|
assert balanced("sum_(i = 1)^n i")
|
|
assert not balanced("(x + 1)^2 + 1)^2 + 1)^2")
|
|
assert not balanced("(-frac(b, 2)")
|
|
assert not balanced("x y z frac(x")
|
|
assert not balanced("(x]")
|
|
|
|
|
|
def test_hand_test_is_well_formed():
|
|
rows = read_jsonl("eval/hand_test.jsonl")
|
|
assert len(rows) >= 100
|
|
assert all(set(r) == {"en", "typ", "cat"} for r in rows)
|
|
assert all(balanced(r["typ"]) for r in rows)
|
|
assert all(compiles_many([r["typ"] for r in rows]))
|
|
dupes = [en for en, k in collections.Counter(r["en"] for r in rows).items() if k > 1]
|
|
assert not dupes, dupes
|