MCPcopy Index your code
hub / github.com/dmlc/dgl / __init__

Method __init__

python/dgl/frame.py:588–617  ·  view source on GitHub ↗
(self, data=None, num_rows=None)

Source from the content-addressed store, hash-verified

586 """
587
588 def __init__(self, data=None, num_rows=None):
589 if data is None:
590 self._columns = dict()
591 self._num_rows = 0 if num_rows is None else num_rows
592 else:
593 assert not isinstance(data, Frame) # sanity check for code refactor
594 # Note that we always create a new column for the given data.
595 # This avoids two frames accidentally sharing the same column.
596 self._columns = {
597 k: v if isinstance(v, LazyFeature) else Column.create(v)
598 for k, v in data.items()
599 }
600 self._num_rows = num_rows
601 # infer num_rows & sanity check
602 for name, col in self._columns.items():
603 if isinstance(col, LazyFeature):
604 continue
605 if self._num_rows is None:
606 self._num_rows = len(col)
607 elif len(col) != self._num_rows:
608 raise DGLError(
609 "Expected all columns to have same # rows (%d), "
610 "got %d on %r." % (self._num_rows, len(col), name)
611 )
612
613 # Initializer for empty values. Initializer is a callable.
614 # If is none, then a warning will be raised
615 # in the first call and zero initializer will be used later.
616 self._initializers = {} # per-column initializers
617 self._default_initializer = None
618
619 def _set_zero_default_initializer(self):
620 """Set the default initializer to be zero initializer."""

Callers 1

__init__Method · 0.45

Calls 3

DGLErrorClass · 0.85
createMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected