diff --git a/lib/symmath/__init__.py b/lib/symmath/__init__.py new file mode 100644 index 0000000000..6a5632c001 --- /dev/null +++ b/lib/symmath/__init__.py @@ -0,0 +1,2 @@ +from formula import * +from symmath_check import * diff --git a/lib/sympy_check/formula.py b/lib/symmath/formula.py similarity index 99% rename from lib/sympy_check/formula.py rename to lib/symmath/formula.py index 81acef614d..bfff38996d 100644 --- a/lib/sympy_check/formula.py +++ b/lib/symmath/formula.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # # File: formula.py -# Date: 04-May-12 +# Date: 04-May-12 (creation) # Author: I. Chuang # # flexible python representation of a symbolic mathematical formula. diff --git a/lib/sympy_check/sympy_check2.py b/lib/symmath/symmath_check.py similarity index 93% rename from lib/sympy_check/sympy_check2.py rename to lib/symmath/symmath_check.py index 320f70abe8..89ae219bc1 100644 --- a/lib/sympy_check/sympy_check2.py +++ b/lib/symmath/symmath_check.py @@ -1,11 +1,10 @@ #!/usr/bin/python # -*- coding: utf-8 -*- # -# File: sympy_check2.py -# Date: 02-May-12 -# Author: I. Chuang +# File: symmath_check.py +# Date: 02-May-12 (creation) # -# Use sympy to check for expression equality +# Symbolic mathematical expression checker for edX. Uses sympy to check for expression equality. # # Takes in math expressions given as Presentation MathML (from ASCIIMathML), converts to Content MathML using SnuggleTeX @@ -15,11 +14,13 @@ from formula import * #----------------------------------------------------------------------------- # check function interface +# +# This is one of the main entry points to call. -def sympy_check_simple(expect,ans,adict={},symtab=None,extra_options=None): +def symmath_check_simple(expect,ans,adict={},symtab=None,extra_options=None): ''' Check a symbolic mathematical expression using sympy. - The input is an ascii string (not MathML) + The input is an ascii string (not MathML) converted to math using sympy.sympify. ''' options = {'__MATRIX__':False,'__ABC__':False,'__LOWER__':False} @@ -133,11 +134,13 @@ def check(expect,given,numerical=False,matrix=False,normphase=False,abcsym=False #----------------------------------------------------------------------------- # Check function interface, which takes pmathml input +# +# This is one of the main entry points to call. -def sympy_check(expect,ans,adict={},abname=''): +def symmath_check(expect,ans,adict={},abname=''): ''' Check a symbolic mathematical expression using sympy. - The input may be presentation MathML + The input may be presentation MathML. Uses formula. ''' msg = '' @@ -231,6 +234,9 @@ def sympy_check(expect,ans,adict={},abname=''): return {'ok':False,'msg':msg,'ex':fexpect,'got':fsym} +#----------------------------------------------------------------------------- +# tests + def sctest1(): x = "1/2*(1+(k_e* Q* q)/(m *g *h^2))" y = ''' diff --git a/lib/sympy_check/__init__.py b/lib/sympy_check/__init__.py deleted file mode 100644 index 0a990657ca..0000000000 --- a/lib/sympy_check/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from formula import * -from sympy_check2 import *