Open SergiyKolesnikov opened 7 years ago
I am getting a TypeError when I try to convert an AST back to an expression (pyeda 0.28.0):
import pyeda.inter as eda
my_expr = eda.expr('A => B')
print(my_expr)
my_expr_ast = my_expr.to_ast()
print(my_expr_ast)
eda.ast2expr(my_expr_ast)
Output:
Implies(A, B)
('impl', ('lit', 1), ('lit', 2))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-4e111d968d2f> in <module>()
4 my_expr_ast = my_expr.to_ast()
5 print(my_expr_ast)
----> 6 eda.ast2expr(my_expr_ast)
/anaconda3/lib/python3.5/site-packages/pyeda/boolalg/expr.py in ast2expr(ast)
235 return exprvar(ast[1], ast[2])
236 else:
--> 237 xs = [ast2expr(x) for x in ast[1:]]
238 return ASTOPS[ast[0]](*xs, simplify=False)
239
/anaconda3/lib/python3.5/site-packages/pyeda/boolalg/expr.py in <listcomp>(.0)
235 return exprvar(ast[1], ast[2])
236 else:
--> 237 xs = [ast2expr(x) for x in ast[1:]]
238 return ASTOPS[ast[0]](*xs, simplify=False)
239
/anaconda3/lib/python3.5/site-packages/pyeda/boolalg/expr.py in ast2expr(ast)
235 return exprvar(ast[1], ast[2])
236 else:
--> 237 xs = [ast2expr(x) for x in ast[1:]]
238 return ASTOPS[ast[0]](*xs, simplify=False)
239
/anaconda3/lib/python3.5/site-packages/pyeda/boolalg/expr.py in <listcomp>(.0)
235 return exprvar(ast[1], ast[2])
236 else:
--> 237 xs = [ast2expr(x) for x in ast[1:]]
238 return ASTOPS[ast[0]](*xs, simplify=False)
239
/anaconda3/lib/python3.5/site-packages/pyeda/boolalg/expr.py in ast2expr(ast)
230 def ast2expr(ast):
231 """Convert an abstract syntax tree to an Expression."""
--> 232 if ast[0] == 'const':
233 return _CONSTS[ast[1]]
234 elif ast[0] == 'var':
TypeError: 'int' object is not subscriptable
Currently it is impossible to save a pyeda expression in a file using pickle:
For long running computations it is often useful to save intermediate results using pickle.
Meanwhile, I use DIMACS export to store expressions to a file and restore them: