Either
|
def next(self) -> str: |
|
assert not self.empty(), "Cannot pick clip from empty pool" |
|
|
|
# find a clip that is not in the recent history |
|
idx = random.randrange(0, len(self.clips)) |
|
while idx in self._history: |
|
idx = random.randrange(0, len(self.clips)) |
|
|
|
# add to recent history |
|
self._history.append(idx) |
|
if len(self._history) > self._history_len: |
|
del self._history[0] |
|
|
|
return self.clips[idx] |
is not working or
_history_len
has an incorrect value.