2020Arguments. The non-constant arguments are accessible as attributes of the
2121Equation instance and can be passed as arguments to __call__.
2222
23- Example
24- > # make a Literal tree. Here's a simple one
25- > add = AdditionOperator()
26- > a = Argument(name="a") # Don't forget to name these!
27- > b = Argument(name="b")
28- > add.addLiteral(a)
29- > add.addLiteral(b)
30- > # make an Equation instance and pass the root
31- > eq = Equation(root = add)
32- > eq(a=3, b=4) # returns 7
33- > eq(a=2) # remembers b=4, returns 6
34- > eq.a.setValue(-3)
35- > eq.b.setValue(3)
36- > eq() # uses last assignment of a and b, returns 0
23+ Example > # make a Literal tree. Here's a simple one > add = AdditionOperator()
24+ > a = Argument(name="a") # Don't forget to name these! > b = Argument(name="b")
25+ > add.addLiteral(a) > add.addLiteral(b) > # make an Equation instance and pass
26+ the root > eq = Equation(root = add) > eq(a=3, b=4) # returns 7 > eq(a=2) #
27+ remembers b=4, returns 6 > eq.a.setValue(-3) > eq.b.setValue(3) > eq() # uses
28+ last assignment of a and b, returns 0
3729
3830See the class documentation for more information.
3931"""
@@ -88,7 +80,6 @@ def __init__(self, name = None, root = None):
8880 root -- The root node of the Literal tree (default None). If root
8981 is not passed here, you must call the 'setRoot' method to
9082 set or change the root node.
91-
9283 """
9384 # Operator stuff. We circumvent Operator.__init__ since we're using
9485 # args as a property. We cannot set it, as the Operator tries to do.
@@ -110,8 +101,8 @@ def symbol(self):
110101 def operation (self , * args , ** kw ):
111102 """Evaluate this Equation object.
112103
113- Same as the __call__ method. This method is used via
114- the Operator interface.
104+ Same as the __call__ method. This method is used via the Operator
105+ interface.
115106
116107 Return the result of __call__(*args, **kw).
117108 """
@@ -150,7 +141,6 @@ def setRoot(self, root):
150141
151142 Raises:
152143 ValueError if errors are found in the Literal tree.
153-
154144 """
155145
156146 # Validate the new root
@@ -179,11 +169,10 @@ def __call__(self, *args, **kw):
179169 """Call the equation.
180170
181171 New Argument values are acceped as arguments or keyword assignments (or
182- both). The order of accepted arguments is given by the args
183- attribute. The Equation will remember values set in this way.
172+ both). The order of accepted arguments is given by the args attribute.
173+ The Equation will remember values set in this way.
184174
185- Raises
186- ValueError when a passed argument cannot be found
175+ Raises ValueError when a passed argument cannot be found
187176 """
188177 # Process args
189178 for idx , val in enumerate (args ):
@@ -206,7 +195,6 @@ def swap(self, oldlit, newlit):
206195 """Swap a literal in the equation for another.
207196
208197 Note that this may change the root and the operation interface
209-
210198 """
211199 newroot = swap (self .root , oldlit , newlit )
212200 self .setRoot (newroot )
0 commit comments