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

Method _g_create

tables/vlarray.py:396–438  ·  view source on GitHub ↗

Create a variable length array (ragged array).

(self)

Source from the content-addressed store, hash-verified

394 return (SizeType(chunkshape),)
395
396 def _g_create(self) -> int:
397 """Create a variable length array (ragged array)."""
398 atom = self.atom
399 self._v_version = obversion
400 # Check for zero dims in atom shape (not allowed in VLArrays)
401 zerodims = np.sum(np.array(atom.shape) == 0)
402 if zerodims > 0:
403 raise ValueError(
404 "When creating VLArrays, none of the dimensions "
405 "of the Atom instance can be zero."
406 )
407
408 if not hasattr(atom, "size"): # it is a pseudo-atom
409 self._atomicdtype = atom.base.dtype
410 self._atomicsize = atom.base.size
411 self._basesize = atom.base.itemsize
412 else:
413 self._atomicdtype = atom.dtype
414 self._atomicsize = atom.size
415 self._basesize = atom.itemsize
416 self._atomictype = atom.type
417 self._atomicshape = atom.shape
418
419 # Compute the optimal chunkshape, if needed
420 if self._v_chunkshape is None:
421 self._v_chunkshape = self._calc_chunkshape(self._v_expectedrows)
422
423 self.nrows = SizeType(0) # No rows at creation time
424
425 # Correct the byteorder if needed
426 if self.byteorder is None:
427 self.byteorder = correct_byteorder(atom.type, sys.byteorder)
428
429 # After creating the vlarray, ``self._v_objectid`` needs to be
430 # set because it is needed for setting attributes afterwards.
431 self._v_objectid = self._create_array(self._v_new_title)
432
433 # Add an attribute in case we have a pseudo-atom so that we
434 # can retrieve the proper class after a re-opening operation.
435 if not hasattr(atom, "size"): # it is a pseudo-atom
436 self.attrs.PSEUDOATOM = atom.kind
437
438 return self._v_objectid
439
440 def _g_open(self) -> int:
441 """Get the metadata info for an array in file."""

Callers

nothing calls this directly

Calls 2

_calc_chunkshapeMethod · 0.95
correct_byteorderFunction · 0.85

Tested by

no test coverage detected