From e21caab2b047887cd6b2af8a1ee2c5cd86717a3b Mon Sep 17 00:00:00 2001 From: Jonathan Gutow Date: Sun, 5 Jun 2022 17:19:07 -0500 Subject: [PATCH] add preparser.html to git --- docs/algebra_with_sympy/preparser.html | 381 +++++++++++++++++++++++++ 1 file changed, 381 insertions(+) create mode 100644 docs/algebra_with_sympy/preparser.html diff --git a/docs/algebra_with_sympy/preparser.html b/docs/algebra_with_sympy/preparser.html new file mode 100644 index 0000000..038d215 --- /dev/null +++ b/docs/algebra_with_sympy/preparser.html @@ -0,0 +1,381 @@ + + + + + + + algebra_with_sympy.preparser API documentation + + + + + + + + + + + + +
+
+

+algebra_with_sympy.preparser

+ + + + + + +
 1def algebra_with_sympy_preparser(lines):
+ 2    """
+ 3    In IPython compatible environments (Jupyter, IPython, etc...) this supports
+ 4    a special compact input method for equations.
+ 5
+ 6    The syntax supported is `equation_name =@ equation.lhs = equation.rhs`,
+ 7    where `equation_name` is a valid Python name that can be used to refer to
+ 8    the equation later. `equation.lhs` is the left-hand side of the equation
+ 9    and `equation.rhs` is the right-hand side of the equation. Each side of the
+10    equation must parse into a valid Sympy expression.
+11
+12    **Note**: If the `equation_name` is omitted the equation will be formed,
+13    but it will
+14    not be assigned to a name that can be used to refer to it later. You may be
+15    able to access it through one of the special IPython underscore names. This
+16    is not recommended.
+17
+18    **THIS FUNCTION IS USED BY THE IPYTHON ENVIRONMENT TO PREPARSE THE INPUT
+19    BEFORE IT IS PASSED TO THE PYTHON INTERPRETER. IT IS NOT MEANT TO BE USED
+20    DIRECTLY BY A USER**
+21    """
+22    new_lines = []
+23    for k in lines:
+24        if '=@' in k:
+25            linesplit = k.split('=@')
+26            eqsplit = linesplit[1].split('=')
+27            if len(eqsplit)!=2:
+28                raise ValueError('The two sides of the equation must be' \
+29                                 ' separated by an \"=\" sign when using' \
+30                                 ' the \"=*\" special input method.')
+31            templine =''
+32            if eqsplit[0]!='' and eqsplit[1]!='':
+33                if linesplit[0]!='':
+34                    templine = str(linesplit[0])+'=Eqn('+str(eqsplit[0])+',' \
+35                        ''+str(eqsplit[1])+')\n'
+36                else:
+37                    templine = 'Eqn('+str(eqsplit[0])+','+str(eqsplit[1])+')\n'
+38            new_lines.append(templine)
+39        else:
+40            new_lines.append(k+'\n')
+41    return(new_lines)
+42
+43from IPython import get_ipython
+44if get_ipython():
+45    get_ipython().input_transformers_cleanup.append(algebra_with_sympy_preparser)
+
+ + +
+
+ +
+ + def + algebra_with_sympy_preparser(lines) + + + +
+ +
 2def algebra_with_sympy_preparser(lines):
+ 3    """
+ 4    In IPython compatible environments (Jupyter, IPython, etc...) this supports
+ 5    a special compact input method for equations.
+ 6
+ 7    The syntax supported is `equation_name =@ equation.lhs = equation.rhs`,
+ 8    where `equation_name` is a valid Python name that can be used to refer to
+ 9    the equation later. `equation.lhs` is the left-hand side of the equation
+10    and `equation.rhs` is the right-hand side of the equation. Each side of the
+11    equation must parse into a valid Sympy expression.
+12
+13    **Note**: If the `equation_name` is omitted the equation will be formed,
+14    but it will
+15    not be assigned to a name that can be used to refer to it later. You may be
+16    able to access it through one of the special IPython underscore names. This
+17    is not recommended.
+18
+19    **THIS FUNCTION IS USED BY THE IPYTHON ENVIRONMENT TO PREPARSE THE INPUT
+20    BEFORE IT IS PASSED TO THE PYTHON INTERPRETER. IT IS NOT MEANT TO BE USED
+21    DIRECTLY BY A USER**
+22    """
+23    new_lines = []
+24    for k in lines:
+25        if '=@' in k:
+26            linesplit = k.split('=@')
+27            eqsplit = linesplit[1].split('=')
+28            if len(eqsplit)!=2:
+29                raise ValueError('The two sides of the equation must be' \
+30                                 ' separated by an \"=\" sign when using' \
+31                                 ' the \"=*\" special input method.')
+32            templine =''
+33            if eqsplit[0]!='' and eqsplit[1]!='':
+34                if linesplit[0]!='':
+35                    templine = str(linesplit[0])+'=Eqn('+str(eqsplit[0])+',' \
+36                        ''+str(eqsplit[1])+')\n'
+37                else:
+38                    templine = 'Eqn('+str(eqsplit[0])+','+str(eqsplit[1])+')\n'
+39            new_lines.append(templine)
+40        else:
+41            new_lines.append(k+'\n')
+42    return(new_lines)
+
+ + +

In IPython compatible environments (Jupyter, IPython, etc...) this supports +a special compact input method for equations.

+ +

The syntax supported is equation_name =@ equation.lhs = equation.rhs, +where equation_name is a valid Python name that can be used to refer to +the equation later. equation.lhs is the left-hand side of the equation +and equation.rhs is the right-hand side of the equation. Each side of the +equation must parse into a valid Sympy expression.

+ +

Note: If the equation_name is omitted the equation will be formed, +but it will +not be assigned to a name that can be used to refer to it later. You may be +able to access it through one of the special IPython underscore names. This +is not recommended.

+ +

THIS FUNCTION IS USED BY THE IPYTHON ENVIRONMENT TO PREPARSE THE INPUT +BEFORE IT IS PASSED TO THE PYTHON INTERPRETER. IT IS NOT MEANT TO BE USED +DIRECTLY BY A USER

+
+ + +
+
+ + \ No newline at end of file