Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
Finilized version 1.1 Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
glenfletcher committed May 2, 2014
1 parent 77672ff commit 5019f4f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
25 changes: 22 additions & 3 deletions Equation/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,32 @@ class Expression( object ):
This is a object that respresents an equation string in a manner
that allows for it to be evaluated
Arithmetic Operators:
Expression objects support combining with the standard arithmetic operators
to create new Expression objects, they may also be combined with numerical
constant, and strings containg a valid Expression.
>>> from Equation import Expression
>>> fn = Expression("x")
>>> fn += 2
>>> fn
(x + 2)
>>> fn **=3
>>> fn
((x + 2) ^ 3)
>>> fn -= "z"
>>> fn
(((x + 2) ^ 3) - z)
>>> fn(1,2)
25
Parameters
----------
expression: str
String resprenstation of an equation
argorder: list of str
List of variable names, indicating the position of variable
for mapping from positional arguments
for mapping from positional arguments
"""
def __init__(self,expression,argorder=[],*args,**kwargs):
super(Expression,self).__init__(*args,**kwargs)
Expand Down Expand Up @@ -433,7 +452,7 @@ def __rcombine(self,other,op):
else:
obj = type(self)(self)
if isinstance(other,(int,float,complex)):
obj.__expr.insert(0,ExpressionValue(other,obj))
obj.__expr.insert(0,ExpressionValue(other))
else:
if isinstance(other,basestring):
try:
Expand Down Expand Up @@ -462,7 +481,7 @@ def __icombine(self,other,op):
else:
obj = self
if isinstance(other,(int,float,complex)):
obj.__expr.append(ExpressionValue(other,obj))
obj.__expr.append(ExpressionValue(other))
else:
if isinstance(other,basestring):
try:
Expand Down
11 changes: 10 additions & 1 deletion doc/source/Equation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ Modules

.. method:: var in fn

:returns: True if `fn` has a preset variable `var`
:returns: True if `fn` has a variable `var`

.. method:: var not in fn

:returns: True if `fn` dosen't have a variable `var`

.. method:: for var in fn

Iterates over all variables `var` in `fn`

.. method:: str(fn)

Expand All @@ -46,5 +54,6 @@ Modules

:returns: Convert the Expression to a String that passed to the constructor, will constuct an identical equation object (in terms of sequence of tokens, and token type/value)


.. automodule:: Equation.similar
:members:

0 comments on commit 5019f4f

Please sign in to comment.