@@ -81,7 +81,7 @@ def shuffled(iterable):
8181 "Randomly shuffle a copy of iterable."
8282 items = list (iterable )
8383 random .shuffle (items )
84- return items
84+ return items
8585
8686
8787
@@ -345,16 +345,16 @@ def unimplemented():
345345# See https://docs.python.org/3/reference/expressions.html#operator-precedence
346346# See https://docs.python.org/3/reference/datamodel.html#special-method-names
347347
348- class Expr (object ):
348+ class Expr (object ):
349349 """A mathematical expression with an operator and 0 or more arguments.
350350 op is a str like '+' or 'sin'; args are Expressions.
351351 Expr('x') or Symbol('x') creates a symbol (a nullary Expr).
352352 Expr('-', x) creates a unary; Expr('+', x, 1) creates a binary."""
353-
354- def __init__ (self , op , * args ):
353+
354+ def __init__ (self , op , * args ):
355355 self .op = str (op )
356356 self .args = args
357-
357+
358358 # Operator overloads
359359 def __neg__ (self ): return Expr ('-' , self )
360360 def __pos__ (self ): return Expr ('+' , self )
@@ -374,10 +374,10 @@ def __matmul__(self, rhs): return Expr('@', self, rhs)
374374
375375 def __or__ (self , rhs ):
376376 if isinstance (rhs , Expression ) :
377- return Expr ('|' , self , rhs )
377+ return Expr ('|' , self , rhs )
378378 else :
379379 return NotImplemented # So that InfixOp can handle it
380-
380+
381381 # Reverse operator overloads
382382 def __radd__ (self , lhs ): return Expr ('+' , lhs , self )
383383 def __rsub__ (self , lhs ): return Expr ('-' , lhs , self )
@@ -393,20 +393,20 @@ def __rlshift__(self, lhs): return Expr('<<', lhs, self)
393393 def __rtruediv__ (self , lhs ): return Expr ('/' , lhs , self )
394394 def __rfloordiv__ (self , lhs ): return Expr ('//' , lhs , self )
395395 def __rmatmul__ (self , lhs ): return Expr ('@' , lhs , self )
396-
397- def __call__ (self , * args ):
396+
397+ def __call__ (self , * args ):
398398 "Call: if 'f' is a Symbol, then f(0) == Expr('f', 0)."
399399 return Expr (self .op , * args )
400400
401401 # Equality and repr
402- def __eq__ (self , other ):
402+ def __eq__ (self , other ):
403403 "'x == y' evaluates to True or False; does not build an Expr."
404- return (isinstance (other , Expr )
405- and self .op == other .op
404+ return (isinstance (other , Expr )
405+ and self .op == other .op
406406 and self .args == other .args )
407-
407+
408408 def __hash__ (self ): return hash (self .op ) ^ hash (self .args )
409-
409+
410410 def __repr__ (self ):
411411 op = self .op
412412 args = [str (arg ) for arg in self .args ]
@@ -450,7 +450,7 @@ def arity(expression):
450450
451451class InfixOp :
452452 """Allow 'P |implies| Q, where P, Q are Exprs and implies is an InfixOp."""
453- def __init__ (self , op , lhs = None ): self .op , self .lhs = op , lhs
453+ def __init__ (self , op , lhs = None ): self .op , self .lhs = op , lhs
454454 def __call__ (self , lhs , rhs ): return Expr (self .op , lhs , rhs )
455455 def __or__ (self , rhs ): return Expr (self .op , self .lhs , rhs )
456456 def __ror__ (self , lhs ): return InfixOp (self .op , lhs )
@@ -489,7 +489,7 @@ class defaultkeydict(collections.defaultdict):
489489 def __missing__ (self , key ):
490490 self [key ] = result = self .default_factory (key )
491491 return result
492-
492+
493493
494494# ______________________________________________________________________________
495495# Queues: Stack, FIFOQueue, PriorityQueue
@@ -591,9 +591,3 @@ def __delitem__(self, key):
591591 for i , (value , item ) in enumerate (self .A ):
592592 if item == key :
593593 self .A .pop (i )
594-
595- # Fig: The idea is we can define things like Fig[3,10] = ...
596- # TODO: However, this is deprecated, let's remove it,
597- # and instead have a comment like # Figure 3.10
598-
599- Fig = {}
0 commit comments