Mercurial > code > home > repos > homeauto
comparison service/mqtt_to_rdf/inference.py @ 1609:34f2817320cc
new tests for a smaller part of the inner loop
author | drewp@bigasterisk.com |
---|---|
date | Mon, 06 Sep 2021 18:06:11 -0700 |
parents | f928eb06a4f6 |
children | 6fc48ef4c696 |
comparison
equal
deleted
inserted
replaced
1608:f928eb06a4f6 | 1609:34f2817320cc |
---|---|
47 self.lhsBnodes.update(x for x in varsAndBnodesInStmt if isinstance(x, BNode)) | 47 self.lhsBnodes.update(x for x in varsAndBnodesInStmt if isinstance(x, BNode)) |
48 if not varsAndBnodesInStmt: | 48 if not varsAndBnodesInStmt: |
49 self.staticRuleStmts.add(ruleStmt) | 49 self.staticRuleStmts.add(ruleStmt) |
50 | 50 |
51 self.evaluations = list(Evaluation.findEvals(self.graph)) | 51 self.evaluations = list(Evaluation.findEvals(self.graph)) |
52 | |
53 def __repr__(self): | |
54 return f"Lhs({graphDump(self.graph)})" | |
52 | 55 |
53 def findCandidateBindings(self, workingSet: ReadOnlyWorkingSet, stats) -> Iterator['BoundLhs']: | 56 def findCandidateBindings(self, workingSet: ReadOnlyWorkingSet, stats) -> Iterator['BoundLhs']: |
54 """bindings that fit the LHS of a rule, using statements from workingSet and functions | 57 """bindings that fit the LHS of a rule, using statements from workingSet and functions |
55 from LHS""" | 58 from LHS""" |
56 log.debug(f'{INDENT*3} nodesToBind: {self.lhsBindables}') | 59 log.debug(f'{INDENT*3} nodesToBind: {self.lhsBindables}') |
141 | 144 |
142 | 145 |
143 @dataclass | 146 @dataclass |
144 class BoundLhs: | 147 class BoundLhs: |
145 lhs: Lhs | 148 lhs: Lhs |
146 binding: CandidateBinding # mutable | |
147 | 149 |
148 def __post_init__(self): | 150 def __post_init__(self): |
149 self.usedByFuncs = Graph(identifier=GRAPH_ID) | 151 self.usedByFuncs = Graph(identifier=GRAPH_ID) |
150 self._applyFunctions() | 152 self._applyFunctions() |
151 | 153 |
185 pass | 187 pass |
186 else: | 188 else: |
187 log.debug(f'{INDENT*5} stmt not known to be true') | 189 log.debug(f'{INDENT*5} stmt not known to be true') |
188 return False | 190 return False |
189 return True | 191 return True |
190 | |
191 | 192 |
192 def _logVerifyBanner(self, boundLhs, workingSet: ReadOnlyWorkingSet, boundUsedByFuncs): | 193 def _logVerifyBanner(self, boundLhs, workingSet: ReadOnlyWorkingSet, boundUsedByFuncs): |
193 if not log.isEnabledFor(logging.DEBUG): | 194 if not log.isEnabledFor(logging.DEBUG): |
194 return | 195 return |
195 | 196 |