MCPcopy Create free account
hub / github.com/alibaba/graph-learn / __init__

Method __init__

graphlearn/python/data/values.py:454–514  ·  view source on GitHub ↗
(self,
               src_ids=None,
               src_type=None,
               dst_ids=None,
               dst_type=None,
               edge_type=None,
               edge_ids=None,
               src_nodes=None,
               dst_nodes=None,
               int_attrs=None,
               float_attrs=None,
               string_attrs=None,
               weights=None,
               labels=None,
               shape=None,
               graph=None)

Source from the content-addressed store, hash-verified

452 """
453
454 def __init__(self,
455 src_ids=None,
456 src_type=None,
457 dst_ids=None,
458 dst_type=None,
459 edge_type=None,
460 edge_ids=None,
461 src_nodes=None,
462 dst_nodes=None,
463 int_attrs=None,
464 float_attrs=None,
465 string_attrs=None,
466 weights=None,
467 labels=None,
468 shape=None,
469 graph=None):
470 super(Edges, self).__init__(int_attrs=None,
471 float_attrs=None,
472 string_attrs=None,
473 weights=weights,
474 labels=labels,
475 shape=shape,
476 graph=graph)
477 if src_ids is not None:
478 src_ids = np.array(src_ids)
479 if edge_ids is not None:
480 edge_ids = np.array(edge_ids)
481 if dst_ids is not None:
482 dst_ids = np.array(dst_ids)
483
484 if shape is None:
485 if src_ids is not None:
486 self._shape = src_ids.shape
487 if edge_ids is not None:
488 self._shape = edge_ids.shape
489 else:
490 real_shape = src_ids.shape if src_ids is not None else edge_ids.shape
491 if np.prod(real_shape) == np.prod(shape):
492 self._shape = shape
493 else:
494 self._shape = real_shape[0:] if len(shape) == 1 else \
495 (int(np.prod(real_shape) / np.prod(shape[1:])), ) + shape[-1:]
496
497 self._src_ids = self._reshape(src_ids)
498 self._src_type = src_type
499 self._dst_ids = self._reshape(dst_ids)
500 self._dst_type = dst_type
501 self._edge_type = edge_type
502 self._edge_ids = self._reshape(edge_ids)
503 self._src_nodes = src_nodes
504 self._dst_nodes = dst_nodes
505
506 if self._src_ids is not None and self._src_nodes is None:
507 self._src_nodes = Nodes(src_ids, src_type, shape=shape, graph=graph)
508
509 if self._dst_ids is not None and self._dst_nodes is None:
510 self._dst_nodes = Nodes(dst_ids, dst_type, shape=shape, graph=graph)
511

Callers

nothing calls this directly

Calls 3

NodesClass · 0.85
_reshapeMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected