Generate equations with long left sides (#13)
Equation left sides are now a single variable (35%), a flat sum of 2-3 simple terms like x^2, 3 x, sin(x)^2 (30%), or a random expression up to depth 3 (35%). Before, x^2 + y^2 = r^2 never appeared in training. Hand-test exact 41.2% -> 47.1%, equation category 42.9% -> 78.6%. Fixes #2 Co-authored-by: Paul Tal <[email protected]>
This commit was merged in pull request #13.
This commit is contained in:
1 parent
40145d1fce
commit
c661773c30
2 files changed
+44
-2
No files matched your search
+10
-1
@@ -1,7 +1,7 @@
|
||||
import collections
|
||||
import random
|
||||
|
||||
from isotope_typst.ast import Frac, Integral, Neg, Num, Pow, Var
|
||||
from isotope_typst.ast import Eq, Frac, Integral, Neg, Num, Pow, Var, walk
|
||||
from isotope_typst.generate import TreeGen, split_of
|
||||
from isotope_typst.render import to_english, to_typst
|
||||
from isotope_typst.validate import compiles_many
|
||||
@@ -33,3 +33,12 @@ def test_english_is_unambiguous():
|
||||
|
||||
def test_split_is_by_structure():
|
||||
assert split_of("x^2") == split_of("x^2")
|
||||
|
||||
|
||||
def test_equations_have_long_left_sides():
|
||||
"""#2: "x^2 + y^2 = r^2" needs left sides deeper than a single operator in the training data."""
|
||||
gen = TreeGen(random.Random(0))
|
||||
eqs = [t for t in (gen.tree() for _ in range(5000)) if isinstance(t, Eq)]
|
||||
deep = [t for t in eqs if sum(1 for _ in walk(t.left)) >= 5]
|
||||
assert len(deep) > 0.15 * len(eqs)
|
||||
assert any(to_typst(t).startswith("x^2 + y^2 = ") for t in (gen.tree() for _ in range(200_000)))
|
||||
Reference in new issue
Block a user