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)
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)
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)
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)
################################ _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
def unpickle(self, fgraph): fgraph.validate = partial(self.validate_, fgraph) fgraph.consistent = partial(self.consistent_, fgraph)
def unpickle(self, fgraph): fgraph.checkpoint = GetCheckpoint(self, fgraph) fgraph.revert = partial(self.revert, fgraph)
################################ _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):