-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflexpytester.py
executable file
·46 lines (34 loc) · 1.18 KB
/
flexpytester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
"""Flexpytester
Usage:
flexpytester -e <expression> -o <outputfile> -i <inputfile> [-t <type>]
flexpytester -h | --help
Options:
-h --help Show this screen.
-e <expression> The expression to convert.
-o <outputfile> The output file.
-i <inputfile> The input file.
-t <type> The type of the numbers, if not specified it is set to float32.
"""
from docopt import docopt
import sympy as sp
def main():
arguments = docopt(__doc__, version='Flexpytester 0.0')
# Create the expression
exprFile = arguments["-e"]
# Read the content of the file and parse it
f = open(exprFile, "r")
expr = f.read()
f.close()
localParams = {'spExpr': None, 'testRanges': None}
globalParams = {'sp': sp}
exec(expr, globalParams, localParams)
spExpr = localParams['spExpr']
testRanges = localParams['testRanges']
if spExpr is None:
print("Error: The expression is not valid")
return
# spExpr = sp.parse_expr(expr, evaluate=False)
# print(srepr(spEXpr))
if __name__ == '__main__':
main()