2022-03-08 02:19:18 +00:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
|
|
|
|
|
|
|
class DummyDataGenerator(ABC):
|
2022-03-11 06:09:09 +00:00
|
|
|
def __init__(self, length=10):
|
|
|
|
self.length = length
|
|
|
|
|
2022-03-08 02:19:18 +00:00
|
|
|
@abstractmethod
|
|
|
|
def generate(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def __iter__(self):
|
2022-03-11 06:09:09 +00:00
|
|
|
self.step = 0
|
2022-03-08 02:19:18 +00:00
|
|
|
return self
|
|
|
|
|
|
|
|
def __next__(self):
|
2022-03-11 06:09:09 +00:00
|
|
|
if self.step < self.length:
|
|
|
|
self.step += 1
|
|
|
|
return self.generate()
|
|
|
|
else:
|
|
|
|
raise StopIteration
|
|
|
|
|
|
|
|
def __len__(self):
|
|
|
|
return self.length
|