From 5a0111b7ce9a1ec21eaee41f94f87768599b8aa2 Mon Sep 17 00:00:00 2001
From: Octave Perrin <operrin@lrtechnologies.fr>
Date: Tue, 3 Dec 2024 14:19:54 +0100
Subject: [PATCH] update python bind

---
 python_binding/graph/pybind_Node.cpp | 50 +++++++++++++++++++++++++---
 1 file changed, 45 insertions(+), 5 deletions(-)

diff --git a/python_binding/graph/pybind_Node.cpp b/python_binding/graph/pybind_Node.cpp
index 9ebae0499..a81330773 100644
--- a/python_binding/graph/pybind_Node.cpp
+++ b/python_binding/graph/pybind_Node.cpp
@@ -24,27 +24,45 @@ namespace Aidge {
 void init_Node(py::module& m) {
     py::class_<Node, std::shared_ptr<Node>>(m, "Node")
     .def(py::init<std::shared_ptr<Operator>, const std::string&>(), py::arg("op"), py::arg("name") = "")
+
     .def("name", &Node::name,
     R"mydelimiter(
     Name of the Node.
+
+    :return: The name of the Node
+    :rtype: string
     )mydelimiter")
+
     .def("clone", (NodePtr (Node::*)() const) &Node::clone,
     R"mydelimiter(
     Clone the Node and its Operator. The new Node has no connection.
+
+    :return: The new cloned Node
+    :rtype: Node
     )mydelimiter")
+
     .def("type", &Node::type,
     R"mydelimiter(
     Type of the node.
+
+    :return: the type of the Node's operator
+    :rtype: string
     )mydelimiter")
 
     .def("attributes", &Node::attributes,
     R"mydelimiter(
     Get attributes.
+
+    :return: The attributes of the Node
+    :rtype: DynamicAttributes
     )mydelimiter")
 
     .def("get_operator", &Node::getOperator,
     R"mydelimiter(
     Get the Operator object of the Node.
+
+    :return: The Node's Operator
+    :rtype: Operator
     )mydelimiter")
 
     .def("set_name", &Node::setName, py::arg("name"),
@@ -53,7 +71,6 @@ void init_Node(py::module& m) {
 
     :param name: New name for the node.
     :type name: str
-    :rtype: str
     )mydelimiter")
 
     .def("create_unique_name", &Node::createUniqueName, py::arg("base_name"),
@@ -62,6 +79,7 @@ void init_Node(py::module& m) {
 
     :param base_name: proposed name for the node.
     :type base_name: str
+    :return: A name that is not yet in use in any of the Node's GraphViews
     :rtype: str
     )mydelimiter")
 
@@ -130,6 +148,8 @@ void init_Node(py::module& m) {
     .def("outputs", &Node::outputs,
     R"mydelimiter(
     Get, for each output of the Node, a list of the children Node and the associated input index connected to it.
+    The parent list size matches the number of outputs of the node.
+    Each sub-list size will match the number of children connected to the n-th output (i.e. if 3 nodes are connected to the 3rd output parent_list[2].size() == 3).
 
     :return: List of a list of connections. When an output is not linked to any child, its list a empty.
     :rtype: list[list[tuple[Node, int]]]
@@ -148,8 +168,9 @@ void init_Node(py::module& m) {
 
     .def("get_nb_inputs", &Node::nbInputs,
     R"mydelimiter(
-    Number of inputs of the Node.
+    Gives the number of inputs of the Node.
 
+    :return: The number of inputs of the Node
     :rtype: int
     )mydelimiter")
 
@@ -158,13 +179,15 @@ void init_Node(py::module& m) {
     Category of a specific input (Data or Param, optional or not).
     Data inputs exclude inputs expecting parameters (weights or bias).
 
+    :return: The inputCategory of the idx-th input of the Node
     :rtype: InputCategory
     )mydelimiter")
 
     .def("get_nb_outputs", &Node::nbOutputs,
     R"mydelimiter(
-    Number of outputs of the Node.
+    Gives the number of outputs of the Node.
 
+    :return: the number our outputs of the Node
     :rtype: int
     )mydelimiter")
 
@@ -172,22 +195,39 @@ void init_Node(py::module& m) {
     R"mydelimiter(
     Get the pointer to parent of the specified input index.
     This pointer is nullptr if no parent is linked to that input.
+
+    :return: The parent of the specified input
+    :rtype: Node
     )mydelimiter")
 
     .def("get_parents", &Node::getParents,R"mydelimiter(
     Get the list of parent Nodes.
     Each input can only be linked to one Node.
     If an input has no linked node, the associated parent is nullptr
+
+    :return: The list of parent Nodes
+    :rtype: List[Node]
     )mydelimiter")
 
     .def("get_children", (std::set<std::shared_ptr<Node>> (Node::*)() const) &Node::getChildren,
     R"mydelimiter(
-    Returns a set of all children of the Node
+    Get the set of children Nodes linked to the current Node.
+    The returned set does not include any nullptr as an output.
+    Node that are several times child of this one (several of its input come from this Node) appear only once
+
+    :return: The set of children of the Node
+    :rtype: Set{Node}
     )mydelimiter")
 
     .def("get_ordered_children", &Node::getOrderedChildren,
     R"mydelimiter(
-    Get ordered children.
+    Get all children of the node
+    The parent vector size matches the number of outputs of the node.
+    Each sub-vector size will match the number of children connected to the n-th output
+    (i.e. if 3 nodes are connected to the 3rd output parent_vec[2].size() == 3).
+
+    :return:The list (main list,size=number of outputs) of lists (one per output of the Node) of children
+    :rtype: List[List[Node]]
     )mydelimiter")
 
     .def("__call__",
-- 
GitLab