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

Method append

tables/vlarray.py:520–555  ·  view source on GitHub ↗

Add a sequence of data to the end of the dataset. This method appends the objects in the sequence to a *single row* in this array. The type and shape of individual objects must be compliant with the atoms in the array. In the case of serialized objects and variable l

(self, sequence: npt.ArrayLike)

Source from the content-addressed store, hash-verified

518 return self.atom.enum
519
520 def append(self, sequence: npt.ArrayLike) -> None:
521 """Add a sequence of data to the end of the dataset.
522
523 This method appends the objects in the sequence to a *single row* in
524 this array. The type and shape of individual objects must be compliant
525 with the atoms in the array. In the case of serialized objects and
526 variable length strings, the object or string to append is itself the
527 sequence.
528
529 """
530 self._g_check_open()
531 self._v_file._check_writable()
532
533 # Prepare the sequence to convert it into a NumPy object
534 atom = self.atom
535 if not hasattr(atom, "size"): # it is a pseudo-atom
536 sequence = atom.toarray(sequence)
537 statom = atom.base
538 else:
539 try: # fastest check in most cases
540 len(sequence)
541 except TypeError:
542 raise TypeError("argument is not a sequence")
543 statom = atom
544
545 if len(sequence) > 0:
546 # The sequence needs to be copied to make the operation safe
547 # to in-place conversion.
548 nparr = convert_to_np_atom2(sequence, statom)
549 nobjects = self._getnobjects(nparr)
550 else:
551 nobjects = 0
552 nparr = None
553
554 self._append(nparr, nobjects)
555 self.nrows += 1
556
557 def iterrows(
558 self,

Callers 2

create_vlarrayMethod · 0.95
_read_coordinatesMethod · 0.45

Calls 5

_getnobjectsMethod · 0.95
convert_to_np_atom2Function · 0.85
_g_check_openMethod · 0.80
_check_writableMethod · 0.80
toarrayMethod · 0.45

Tested by

no test coverage detected