File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 11# coding: utf-8
22# 2021/5/20 @ tongshiwei
3-
3+ import pytest
44from 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 ([{}])
You can’t perform that action at this time.
0 commit comments