Mercurial > code > home > repos > homeauto
comparison service/mqtt_to_rdf/inference.py @ 1696:cdf706cf5f82 master
fix a test (odometer rollover direction)
author | drewp@bigasterisk.com |
---|---|
date | Mon, 27 Sep 2021 22:56:25 -0700 |
parents | 5c2565e63297 |
children | 88f6e9bf69d1 |
comparison
equal
deleted
inserted
replaced
1695:5c2565e63297 | 1696:cdf706cf5f82 |
---|---|
346 for funcPart in itertools.permutations(funcs) if funcs else [tupleOfNoChunks]: | 346 for funcPart in itertools.permutations(funcs) if funcs else [tupleOfNoChunks]: |
347 perm = patternPart + funcPart | 347 perm = patternPart + funcPart |
348 yield perm | 348 yield perm |
349 | 349 |
350 def _advanceTheStack(self, looperRings: List[ChunkLooper]) -> bool: | 350 def _advanceTheStack(self, looperRings: List[ChunkLooper]) -> bool: |
351 | 351 toRestart: List[ChunkLooper] = [] |
352 carry = True # last elem always must advance | 352 pos = len(looperRings) - 1 |
353 for i, ring in reversed(list(enumerate(looperRings))): | 353 while True: |
354 # unlike normal odometer, advancing any earlier ring could invalidate later ones | 354 looperRings[pos].advance() |
355 if carry: | 355 if looperRings[pos].pastEnd(): |
356 odolog.debug(f'{INDENT*4} advanceAll [ring={i}] {ring} carry/advance') | 356 if pos == 0: |
357 ring.advance() | |
358 carry = False | |
359 if ring.pastEnd(): | |
360 if ring is looperRings[0]: | |
361 allRingsDone = [r.pastEnd() for r in looperRings] | |
362 odolog.debug(f'{INDENT*5} advanceAll [ring={i}] {ring} says we done {allRingsDone=}') | |
363 return True | 357 return True |
364 odolog.debug(f'{INDENT*5} advanceAll [ring={i}] {ring} restart') | 358 toRestart.append(looperRings[pos]) |
365 ring.restart() | 359 pos -= 1 |
366 carry = True | 360 else: |
361 break | |
362 for ring in reversed(toRestart): | |
363 ring.restart() | |
367 return False | 364 return False |
368 | 365 |
369 def _assertAllRingsAreValid(self, looperRings): | 366 def _assertAllRingsAreValid(self, looperRings): |
370 if any(ring.pastEnd() for ring in looperRings): # this is an unexpected debug assertion | 367 if any(ring.pastEnd() for ring in looperRings): # this is an unexpected debug assertion |
371 odolog.warning(f'{INDENT*4} some rings started at pastEnd {looperRings}') | 368 odolog.warning(f'{INDENT*4} some rings started at pastEnd {looperRings}') |