Skip to content

Commit ec22eb0

Browse files
committed
[fix] invalid link variables
1 parent 3b1f214 commit ec22eb0

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/test_formula.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding: utf-8
22
# 2021/5/20 @ tongshiwei
3-
3+
import pytest
44
from EduNLP.Formula import Formula, FormulaGroup
55

66

@@ -9,15 +9,26 @@ def test_formula():
99
f = Formula(formula)
1010
f.variable_standardization(inplace=False)
1111
f.variable_standardization(inplace=True)
12-
assert len(f.ast.nodes) == len(f.element)
12+
assert len(f.ast_graph.nodes) == len(f.ast)
1313
f.to_str()
1414

1515
formula = r"\frac{\pi}{2}"
1616
f = Formula(formula, variable_standardization=True)
1717
assert repr(f) == r"<Formula: \frac{\pi}{2}>"
1818

19+
f = Formula(f.ast)
20+
assert f.resetable is False
21+
with pytest.raises(TypeError):
22+
f.reset_ast()
23+
1924
fg = FormulaGroup([r"x + x", r"x + \frac{\pi}{2}"], variable_standardization=True)
2025
for f in fg:
2126
assert f in fg
22-
assert len(fg[0].element) == 3
27+
assert len(fg[0].ast) == 3
2328
fg.to_str()
29+
30+
fg = FormulaGroup(["x", "y", "x"])
31+
assert len(fg.ast) == 3
32+
33+
with pytest.raises(TypeError):
34+
FormulaGroup([{}])

0 commit comments

Comments
 (0)