Skip to content

Commit 1874e78

Browse files
author
Iñigo Gabirondo
committed
Update documentation of to_pyg()
1 parent adfb51f commit 1874e78

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

programl/transform_ops.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def _run_one(graph: ProgramGraph) -> str:
265265
def to_pyg(
266266
graphs: Union[ProgramGraph, Iterable[ProgramGraph]],
267267
timeout: int = 300,
268-
vocabulary: Dict[str, int] = None,
268+
vocabulary: Optional[Dict[str, int]] = None,
269269
executor: Optional[ExecutorLike] = None,
270270
chunksize: Optional[int] = None,
271271
) -> Union[HeteroData, Iterable[HeteroData]]:
@@ -281,6 +281,10 @@ def to_pyg(
281281
graph conversion before raising an error. If multiple inputs are
282282
provided, this timeout is per-input.
283283
284+
:param vocabulary: A dictionary containing ProGraML's vocabulary, where the
285+
keys are the text attribute of the nodes and the values their respective
286+
indexes.
287+
284288
:param executor: An executor object, with method :code:`submit(callable,
285289
*args, **kwargs)` and returning a Future-like object with methods
286290
:code:`done() -> bool` and :code:`result() -> float`. The executor role
@@ -299,16 +303,17 @@ def to_pyg(
299303
"""
300304

301305
def _run_one(graph: ProgramGraph) -> HeteroData:
302-
# 3 lists, one per edge type
303-
# (control, data and call edges)
306+
# 4 lists, one per edge type
307+
# (control, data, call and type edges)
304308
adjacencies = [[], [], [], []]
305309
edge_positions = [[], [], [], []]
306310

307-
# Create the adjacency lists
311+
# Create the adjacency lists and the positions
308312
for edge in graph.edge:
309313
adjacencies[edge.flow].append([edge.source, edge.target])
310314
edge_positions[edge.flow].append(edge.position)
311315

316+
# Store the text attributes
312317
node_text = [node.text for node in graph.node]
313318

314319
vocab_ids = None

0 commit comments

Comments
 (0)