Commit 3c8c5a1e by ichuang

(cleanup cruft) renamed sympy_check stuff to become symmath

parent 52e1f178
from formula import *
from sympy_check2 import *
from symmath_check import *
......@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
#
# File: formula.py
# Date: 04-May-12
# Date: 04-May-12 (creation)
# Author: I. Chuang <ichuang@mit.edu>
#
# flexible python representation of a symbolic mathematical formula.
......
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# File: sympy_check2.py
# Date: 02-May-12
# Author: I. Chuang <ichuang@mit.edu>
# 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 = '''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment