Exemple #1
0
 def unpickle(self, fgraph):
     History.unpickle(self, fgraph)
     Validator.unpickle(self, fgraph)
     fgraph.replace_validate = partial(self.replace_validate, fgraph)
     fgraph.replace_all_validate = partial(self.replace_all_validate,
                                           fgraph)
     fgraph.replace_all_validate_remove = partial(
         self.replace_all_validate_remove, fgraph)
Exemple #2
0
 def on_attach(self, env):
     History.on_attach(self, env)
     Validator.on_attach(self, env)
     for attr in ('replace_validate', 'replace_all_validate'):            
         if hasattr(env, attr):
             raise AlreadyThere("ReplaceValidate feature is already present or in conflict with another plugin.")
     env.replace_validate = partial(self.replace_validate, env)
     env.replace_all_validate = partial(self.replace_all_validate, env)
Exemple #3
0
 def on_attach(self, fgraph):
     History.on_attach(self, fgraph)
     Validator.on_attach(self, fgraph)
     for attr in ("replace_validate", "replace_all_validate"):
         if hasattr(fgraph, attr):
             raise AlreadyThere("ReplaceValidate feature is already present" " or in conflict with another plugin.")
     fgraph.replace_validate = partial(self.replace_validate, fgraph)
     fgraph.replace_all_validate = partial(self.replace_all_validate, fgraph)
     fgraph.replace_all_validate_remove = partial(self.replace_all_validate_remove, fgraph)
Exemple #4
0
 def on_attach(self, env):
     History.on_attach(self, env)
     Validator.on_attach(self, env)
     for attr in ('replace_validate', 'replace_all_validate'):
         if hasattr(env, attr):
             raise AlreadyThere("ReplaceValidate feature is already present"
                                " or in conflict with another plugin.")
     env.replace_validate = partial(self.replace_validate, env)
     env.replace_all_validate = partial(self.replace_all_validate, env)
Exemple #5
0
 def on_attach(self, fgraph):
     for attr in ('validate', 'validate_time'):
         if hasattr(fgraph, attr):
             raise AlreadyThere("Validator feature is already present or in"
                                " conflict with another plugin.")
     # Don't call unpickle here, as ReplaceValidate.on_attach()
     # call to History.on_attach() will call the
     # ReplaceValidate.unpickle and not History.unpickle
     fgraph.validate = partial(self.validate_, fgraph)
     fgraph.consistent = partial(self.consistent_, fgraph)
Exemple #6
0
 def on_attach(self, fgraph):
     History.on_attach(self, fgraph)
     Validator.on_attach(self, fgraph)
     for attr in ('replace_validate', 'replace_all_validate'):
         if hasattr(fgraph, attr):
             raise AlreadyThere("ReplaceValidate feature is already present"
                                " or in conflict with another plugin.")
     fgraph.replace_validate = partial(self.replace_validate, fgraph)
     fgraph.replace_all_validate = partial(self.replace_all_validate,
                                           fgraph)
     fgraph.replace_all_validate_remove = partial(
         self.replace_all_validate_remove, fgraph)
Exemple #7
0
 def on_attach(self, env):
     if hasattr(env, 'checkpoint') or hasattr(env, 'revert'):
         raise AlreadyThere("History feature is already present or in"
                            " conflict with another plugin.")
     self.history[env] = []
     env.checkpoint = lambda: len(self.history[env])
     env.revert = partial(self.revert, env)
Exemple #8
0
 def on_attach(self, fgraph):
     if hasattr(fgraph, 'checkpoint') or hasattr(fgraph, 'revert'):
         raise AlreadyThere("History feature is already present or in"
                            " conflict with another plugin.")
     self.history[fgraph] = []
     fgraph.checkpoint = lambda: len(self.history[fgraph])
     fgraph.revert = partial(self.revert, fgraph)
Exemple #9
0
 def on_attach(self, fgraph):
     if hasattr(fgraph, 'checkpoint') or hasattr(fgraph, 'revert'):
         raise AlreadyThere("History feature is already present or in"
                            " conflict with another plugin.")
     self.history[fgraph] = []
     fgraph.checkpoint = lambda: len(self.history[fgraph])
     fgraph.revert = partial(self.revert, fgraph)
Exemple #10
0
 def on_attach(self, env):
     if self.env is not None:
         raise Exception("A NodeFinder instance can only serve one Env.")
     if hasattr(env, 'get_nodes'):
         raise AlreadyThere("NodeFinder is already present or in conflict with another plugin.")
     self.env = env
     env.get_nodes = partial(self.query, env)
     Bookkeeper.on_attach(self, env)
Exemple #11
0
 def on_attach(self, fgraph):
     if self.fgraph is not None:
         raise Exception("A NodeFinder instance can only serve one FunctionGraph.")
     if hasattr(fgraph, "get_nodes"):
         raise AlreadyThere("NodeFinder is already present or in conflict" " with another plugin.")
     self.fgraph = fgraph
     fgraph.get_nodes = partial(self.query, fgraph)
     Bookkeeper.on_attach(self, fgraph)
Exemple #12
0
 def on_attach(self, fgraph):
     if self.fgraph is not None:
         raise Exception("A NodeFinder instance can only serve one FunctionGraph.")
     if hasattr(fgraph, 'get_nodes'):
         raise AlreadyThere("NodeFinder is already present or in conflict"
                            " with another plugin.")
     self.fgraph = fgraph
     fgraph.get_nodes = partial(self.query, fgraph)
     Bookkeeper.on_attach(self, fgraph)
Exemple #13
0
 def on_attach(self, env):
     if self.env is not None:
         raise Exception("A NodeFinder instance can only serve one Env.")
     if hasattr(env, 'get_nodes'):
         raise AlreadyThere("NodeFinder is already present or in conflict"
                            " with another plugin.")
     self.env = env
     env.get_nodes = partial(self.query, env)
     Bookkeeper.on_attach(self, env)
Exemple #14
0
 def on_attach(self, fgraph):
     if hasattr(fgraph, 'checkpoint') or hasattr(fgraph, 'revert'):
         raise AlreadyThere("History feature is already present or in"
                            " conflict with another plugin.")
     self.history[fgraph] = []
     # Don't call unpickle here, as ReplaceValidate.on_attach()
     # call to History.on_attach() will call the
     # ReplaceValidate.unpickle and not History.unpickle
     fgraph.checkpoint = GetCheckpoint(self, fgraph)
     fgraph.revert = partial(self.revert, fgraph)
Exemple #15
0
################################


_all = {}

def var_lookup(vartype, name, *args, **kwargs):
    sig = (vartype, name)
    if sig in _all:
        return _all[sig]
    else:
        v = vartype(name, *args)
        _all[sig] = v
        return v

Var = partial(var_lookup, FreeVariable)
V = Var
OrV = partial(var_lookup, OrVariable)
NV = partial(var_lookup, NotVariable)


################################


class Unification:
    """
    This class represents a possible unification of a group of variables
    with each other or with tangible values.
    """

    def __init__(self, inplace = False):
Exemple #16
0
 def unpickle(self, fgraph):
     fgraph.checkpoint = GetCheckpoint(self, fgraph)
     fgraph.revert = partial(self.revert, fgraph)
Exemple #17
0
 def unpickle(self, fgraph):
     fgraph.validate = partial(self.validate_, fgraph)
     fgraph.consistent = partial(self.consistent_, fgraph)