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

Method add_column

python/dgl/frame.py:712–742  ·  view source on GitHub ↗

Add a new column to the frame. The frame will be initialized by the initializer. Parameters ---------- name : str The column name. scheme : Scheme The column scheme. ctx : DGLContext The column context.

(self, name, scheme, ctx)

Source from the content-addressed store, hash-verified

710 del self._columns[name]
711
712 def add_column(self, name, scheme, ctx):
713 """Add a new column to the frame.
714
715 The frame will be initialized by the initializer.
716
717 Parameters
718 ----------
719 name : str
720 The column name.
721 scheme : Scheme
722 The column scheme.
723 ctx : DGLContext
724 The column context.
725 """
726 if name in self:
727 dgl_warning(
728 'Column "%s" already exists. Ignore adding this column again.'
729 % name
730 )
731 return
732
733 if self.get_initializer(name) is None:
734 self._set_zero_default_initializer()
735 initializer = self.get_initializer(name)
736 init_data = initializer(
737 (self.num_rows,) + scheme.shape,
738 scheme.dtype,
739 ctx,
740 slice(0, self.num_rows),
741 )
742 self._columns[name] = Column(init_data, scheme)
743
744 def add_rows(self, num_rows):
745 """Add blank rows to this frame.

Callers 2

update_rowMethod · 0.95
_appendMethod · 0.95

Calls 5

get_initializerMethod · 0.95
dgl_warningFunction · 0.85
ColumnClass · 0.85
initializerFunction · 0.50

Tested by

no test coverage detected