MCPcopy
hub / github.com/dmlc/dgl / add_rows

Method add_rows

python/dgl/frame.py:744–770  ·  view source on GitHub ↗

Add blank rows to this frame. For existing fields, the rows will be extended according to their initializers. Parameters ---------- num_rows : int The number of new rows

(self, num_rows)

Source from the content-addressed store, hash-verified

742 self._columns[name] = Column(init_data, scheme)
743
744 def add_rows(self, num_rows):
745 """Add blank rows to this frame.
746
747 For existing fields, the rows will be extended according to their
748 initializers.
749
750 Parameters
751 ----------
752 num_rows : int
753 The number of new rows
754 """
755 feat_placeholders = {}
756 for key, col in self._columns.items():
757 scheme = col.scheme
758 ctx = F.context(col.data)
759 if self.get_initializer(key) is None:
760 self._set_zero_default_initializer()
761 initializer = self.get_initializer(key)
762 new_data = initializer(
763 (num_rows,) + scheme.shape,
764 scheme.dtype,
765 ctx,
766 slice(self._num_rows, self._num_rows + num_rows),
767 )
768 feat_placeholders[key] = new_data
769 self._append(Frame(feat_placeholders))
770 self._num_rows += num_rows
771
772 def update_column(self, name, data):
773 """Add or replace the column with the given name and data.

Callers 2

add_nodesMethod · 0.80
add_edgesMethod · 0.80

Calls 7

get_initializerMethod · 0.95
_appendMethod · 0.95
FrameClass · 0.85
contextMethod · 0.80
initializerFunction · 0.50
itemsMethod · 0.45

Tested by

no test coverage detected