Mercurial > code > home > repos > homeauto
changeset 1693:0455a1e18e4f
really rough fix to a broken test. hopefully this gets redone
author | drewp@bigasterisk.com |
---|---|
date | Sat, 25 Sep 2021 22:20:42 -0700 |
parents | 2883da14847c |
children | 73abfd4cf5d0 |
files | service/mqtt_to_rdf/inference.py |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/service/mqtt_to_rdf/inference.py Sat Sep 25 22:20:00 2021 -0700 +++ b/service/mqtt_to_rdf/inference.py Sat Sep 25 22:20:42 2021 -0700 @@ -85,6 +85,7 @@ if self._pastEnd: raise NotImplementedError('need restart') ringlog.debug('') + self._currentIsFromFunc = None augmentedWorkingSet: List[AlignedRuleChunk] = [] if self.prev is None: augmentedWorkingSet = self._alignedMatches @@ -139,6 +140,7 @@ pass else: if newBinding is not None: + self._currentIsFromFunc = fn if self._testAndKeepNewBinding(newBinding): return True @@ -183,6 +185,14 @@ if self.pastEnd(): raise NoOptions() + def prevMayHaveChanged(self): + # This is a total patch for a test failure. This should be generalized + # to a Looper that can keep itself correct when prev changes. + if self._currentIsFromFunc: + self._advanceWithFunctions() + if self.pastEnd(): + self.restart() + @dataclass class Lhs: @@ -324,12 +334,18 @@ yield perm def _advanceTheStack(self, looperRings: List[ChunkLooper]) -> bool: + + def freshenRight(i): + for ring in looperRings[i + 1:]: + ring.prevMayHaveChanged() + carry = True # last elem always must advance for i, ring in reversed(list(enumerate(looperRings))): # unlike normal odometer, advancing any earlier ring could invalidate later ones if carry: odolog.debug(f'{INDENT*4} advanceAll [ring={i}] {ring} carry/advance') ring.advance() + freshenRight(i) carry = False if ring.pastEnd(): if ring is looperRings[0]: @@ -338,6 +354,7 @@ return True odolog.debug(f'{INDENT*5} advanceAll [ring={i}] {ring} restart') ring.restart() + freshenRight(i) carry = True return False