polybori.context
index
polybori/context.py

 
Modules
       
polybori

 
Classes
       
__builtin__.object
FactoryContext
RingContext

 
class FactoryContext(__builtin__.object)
    Temporarily exchange the constructor of a given type with a compatible
callable object. It is useful together with the with statement.
 
Example:
>>> r = Ring(1000)
>>> from polybori import Variable
>>> def var(idx): return Variable(idx, r)
>>> with FactoryContext(Variable, var):
...     print Variable(17)
x(17)
>>> try:
...     print Variable(17)
... except:
...     print "caught expected exception"
caught expected exception
 
  Methods defined here:
__enter__(self)
__exit__(self, type, value, traceback)
__init__(self, original, factory)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class RingContext(__builtin__.object)
    Temporarily fix the ring for constructors of some ring-dependent types
like Variable and Monomial to a given ring. It is useful together with
the with statement.
 
Example:
>>> r = Ring(1000)
>>> from polybori import Variable
>>> print Variable(17, r)
x(17)
>>> with RingContext(r):
...     print Variable(17), Monomial(), Polynomial(0), BooleSet()
x(17) 1 0 {}
>>> try:
...     print Variable(17)
... except:
...     print "caught expected exception"
caught expected exception
 
  Methods defined here:
__enter__(self)
__exit__(self, type, value, traceback)
__init__(self, ring)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)