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

Method test02_sssEArray

tables/tests/test_earray.py:224–302  ·  view source on GitHub ↗

Checking enlargeable array iterator with (start, stop, step)

(self)

Source from the content-addressed store, hash-verified

222 self.assertEqual(self.fletcher32, earray.filters.fletcher32)
223
224 def test02_sssEArray(self):
225 """Checking enlargeable array iterator with (start, stop, step)"""
226
227 if common.verbose:
228 print("\n", "-=" * 30)
229 print("Running %s.test02_sssEArray..." % self.__class__.__name__)
230
231 # Create an instance of an HDF5 Table
232 if self.reopen:
233 self._reopen()
234 earray = self.h5file.get_node("/earray1")
235
236 # Choose a small value for buffer size
237 earray.nrowsinbuf = 3
238 if common.verbose:
239 print("EArray descr:", repr(earray))
240 print("shape of read array ==>", earray.shape)
241 print("reopening?:", self.reopen)
242
243 # Build the array to do comparisons
244 if self.type == "string":
245 object_ = np.ndarray(
246 buffer=b"a" * self.objsize,
247 shape=self.rowshape,
248 dtype="S%s" % earray.atom.itemsize,
249 )
250 else:
251 object_ = np.arange(self.objsize, dtype=earray.atom.dtype.base)
252 object_.shape = self.rowshape
253 object_ = object_.swapaxes(earray.extdim, 0)
254
255 if self.obj is not None:
256 initialrows = len(self.obj)
257 else:
258 initialrows = 0
259
260 shape = self._get_shape()
261
262 # Read all the array
263 for idx, row in enumerate(
264 earray.iterrows(start=self.start, stop=self.stop, step=self.step)
265 ):
266 if idx < initialrows:
267 self.assertTrue(
268 common.allequal(
269 row, np.asarray(self.obj[idx]), self.flavor
270 )
271 )
272 continue
273
274 if self.chunksize == 1:
275 index = 0
276 else:
277 index = int((earray.nrow - initialrows) % self.chunksize)
278
279 if self.type == "string":
280 object__ = object_
281 else:

Callers

nothing calls this directly

Calls 4

_get_shapeMethod · 0.95
_reopenMethod · 0.45
get_nodeMethod · 0.45
iterrowsMethod · 0.45

Tested by

no test coverage detected