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 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 #3
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 #4
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 #5
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 #6
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 #7
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 #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] = []
     # 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 #9
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):
        """
        If inplace is False, the merge method will return a new Unification
Exemple #10
0
 def unpickle(self, fgraph):
     fgraph.validate = partial(self.validate_, fgraph)
     fgraph.consistent = partial(self.consistent_, fgraph)
Exemple #11
0
 def unpickle(self, fgraph):
     fgraph.checkpoint = GetCheckpoint(self, fgraph)
     fgraph.revert = partial(self.revert, fgraph)
Exemple #12
0
 def unpickle(self, fgraph):
     fgraph.validate = partial(self.validate_, fgraph)
     fgraph.consistent = partial(self.consistent_, fgraph)
Exemple #13
0
 def unpickle(self, fgraph):
     fgraph.checkpoint = GetCheckpoint(self, fgraph)
     fgraph.revert = partial(self.revert, fgraph)
Exemple #14
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):