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 1
1
# coding: utf-8
2
2
# 2021/5/20 @ tongshiwei
3
-
3
+ import pytest
4
4
from EduNLP .Formula import Formula , FormulaGroup
5
5
6
6
@@ -9,15 +9,26 @@ def test_formula():
9
9
f = Formula (formula )
10
10
f .variable_standardization (inplace = False )
11
11
f .variable_standardization (inplace = True )
12
- assert len (f .ast .nodes ) == len (f .element )
12
+ assert len (f .ast_graph .nodes ) == len (f .ast )
13
13
f .to_str ()
14
14
15
15
formula = r"\frac{\pi}{2}"
16
16
f = Formula (formula , variable_standardization = True )
17
17
assert repr (f ) == r"<Formula: \frac{\pi}{2}>"
18
18
19
+ f = Formula (f .ast )
20
+ assert f .resetable is False
21
+ with pytest .raises (TypeError ):
22
+ f .reset_ast ()
23
+
19
24
fg = FormulaGroup ([r"x + x" , r"x + \frac{\pi}{2}" ], variable_standardization = True )
20
25
for f in fg :
21
26
assert f in fg
22
- assert len (fg [0 ].element ) == 3
27
+ assert len (fg [0 ].ast ) == 3
23
28
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