Making Lookback a subclass of Breakpoint allows using it by itself to generate a state trace on halts
This commit is contained in:
parent
ac3ed72d34
commit
e2fbf38786
1 changed files with 6 additions and 3 deletions
|
@ -101,9 +101,11 @@ class NthBreakpoint:
|
||||||
# FOR EXAMPLE:
|
# FOR EXAMPLE:
|
||||||
# class StepsPlusLookback(Lookback, StepsBreakpoint)
|
# class StepsPlusLookback(Lookback, StepsBreakpoint)
|
||||||
# pass
|
# pass
|
||||||
|
#
|
||||||
|
# ALTERNATIVELY, can be used entirely by itself, and will provide
|
||||||
class Lookback:
|
# a lookback if the run() loop terminates for any reason (e.g., a HALT).
|
||||||
|
#
|
||||||
|
class Lookback(Breakpoint):
|
||||||
|
|
||||||
def __init__(self, *args, lookbacks=100, **kwargs):
|
def __init__(self, *args, lookbacks=100, **kwargs):
|
||||||
self.__backstates = collections.deque([], lookbacks)
|
self.__backstates = collections.deque([], lookbacks)
|
||||||
|
@ -118,6 +120,7 @@ class Lookback:
|
||||||
return list(self.__backstates)
|
return list(self.__backstates)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MultiBreakpoint(Breakpoint):
|
class MultiBreakpoint(Breakpoint):
|
||||||
# a breakpoint that fires if any of the contained breakpoints fire
|
# a breakpoint that fires if any of the contained breakpoints fire
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue