MCPcopy Create free account
hub / github.com/PyTables/PyTables / __next__

Method __next__

tables/array.py:339–373  ·  view source on GitHub ↗

Get the next element of the array during an iteration. The element is returned as an object of the current flavor.

(self)

Source from the content-addressed store, hash-verified

337 self.nrow = SizeType(self._start - self._step) # row number
338
339 def __next__(self) -> Any:
340 """Get the next element of the array during an iteration.
341
342 The element is returned as an object of the current flavor.
343
344 """
345 # this could probably be sped up for long iterations by reusing the
346 # listarr buffer
347 if self._nrowsread >= self._stop:
348 self._init = False
349 self.listarr = None # fixes issue #308
350 raise StopIteration # end of iteration
351 else:
352 # Read a chunk of rows
353 if self._row + 1 >= self.nrowsinbuf or self._row < 0:
354 self._stopb = self._startb + self._step * self.nrowsinbuf
355 # Protection for reading more elements than needed
356 if self._stopb > self._stop:
357 self._stopb = self._stop
358 listarr = self._read(self._startb, self._stopb, self._step)
359 # Swap the axes to easy the return of elements
360 if self.extdim > 0:
361 listarr = listarr.swapaxes(self.extdim, 0)
362 self.listarr = internal_to_flavor(listarr, self.flavor)
363 self._row = -1
364 self._startb = self._stopb
365 self._row += 1
366 self.nrow += self._step
367 self._nrowsread += self._step
368 # Fixes bug #968132
369 # if self.listarr.shape:
370 if self.shape:
371 return self.listarr[self._row]
372 else:
373 return self.listarr # Scalar case
374
375 def _interpret_indexing(
376 self,

Callers

nothing calls this directly

Calls 2

_readMethod · 0.95
internal_to_flavorFunction · 0.85

Tested by

no test coverage detected