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

Method test04_getitemEArray

tables/tests/test_earray.py:534–637  ·  view source on GitHub ↗

Checking enlargeable array __getitem__ special method.

(self)

Source from the content-addressed store, hash-verified

532 self.assertEqual(len(shape), 1)
533
534 def test04_getitemEArray(self):
535 """Checking enlargeable array __getitem__ special method."""
536
537 if common.verbose:
538 print("\n", "-=" * 30)
539 print(
540 "Running %s.test04_getitemEArray..." % self.__class__.__name__
541 )
542
543 if not hasattr(self, "slices"):
544 # If there is not a slices attribute, create it
545 # This conversion made just in case indices are numpy scalars
546 if self.start is not None:
547 self.start = int(self.start)
548 if self.stop is not None:
549 self.stop = int(self.stop)
550 if self.step is not None:
551 self.step = int(self.step)
552 self.slices = (slice(self.start, self.stop, self.step),)
553
554 # Create an instance of an HDF5 Table
555 if self.reopen:
556 self._reopen()
557 earray = self.h5file.get_node("/earray1")
558
559 # Choose a small value for buffer size
560 # earray.nrowsinbuf = 3 # this does not really change the chunksize
561 if common.verbose:
562 print("EArray descr:", repr(earray))
563 print("shape of read array ==>", earray.shape)
564 print("reopening?:", self.reopen)
565
566 # Build the array to do comparisons
567 if self.type == "string":
568 object_ = np.ndarray(
569 buffer=b"a" * self.objsize,
570 shape=self.rowshape,
571 dtype=f"S{earray.atom.itemsize}",
572 )
573 else:
574 object_ = np.arange(self.objsize, dtype=earray.atom.dtype.base)
575 object_.shape = self.rowshape
576
577 object_ = object_.swapaxes(earray.extdim, 0)
578
579 if self.obj is not None:
580 initialrows = len(self.obj)
581 else:
582 initialrows = 0
583
584 rowshape = self.rowshape
585 rowshape[self.extdim] *= self.nappends + initialrows
586 if self.type == "string":
587 object__ = np.empty(
588 shape=rowshape, dtype=f"S{earray.atom.itemsize}"
589 )
590 else:
591 object__ = np.empty(shape=rowshape, dtype=self.dtype)

Callers

nothing calls this directly

Calls 4

_reopenMethod · 0.45
get_nodeMethod · 0.45
copyMethod · 0.45
__getitem__Method · 0.45

Tested by

no test coverage detected