I am sending slices of the memoryview
in numpy.array.data
class AsyncChunker:
def __init__(self, array):
self.chunk_size = 16777216
self.array = array
self.start = 0
def __aiter__(self):
return self
async def __anext__(self):
chunk = self.array.data[self.start: self.start + self.chunk_size] # Not allowed for 0-dim
if len(chunk):
self.start += self.chunk_size
return chunk
raise StopAsyncIteration
The case when self.array.data.ndim == 0
gives TypeError: invalid indexing of 0-dim memory
.
Is there a way to treat uniformly the slicing of memoryview
to cover all dimensions or do I necessarily have to treat the case of 0-dim apart?