From a6a93847cfcdd1a3cddbe1a7626b973180aefce6 Mon Sep 17 00:00:00 2001
From: Charles Villard <charles.villard@cea.fr>
Date: Wed, 19 Mar 2025 17:07:07 +0100
Subject: [PATCH] edit: nodes: update the comments and documentations of new
 functions and clean outputName from warnings

---
 include/aidge/graph/Node.hpp         | 25 ++++++++++-------
 python_binding/graph/pybind_Node.cpp | 42 +++++++++++++++-------------
 src/graph/Node.cpp                   |  4 +--
 3 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/include/aidge/graph/Node.hpp b/include/aidge/graph/Node.hpp
index 917d0a355..c6ac9c651 100644
--- a/include/aidge/graph/Node.hpp
+++ b/include/aidge/graph/Node.hpp
@@ -227,26 +227,19 @@ public:
 
   /**
    * @brief Name of the input.
-   * If the input is not linked to any Parent, the value is "".
    * @param inID
    * @return std::string
    */
   std::string inputName(const IOIndex_t inID) const;
 
   /**
-   * @brief Name of the input.
-   * If the input is not linked to any Parent, the value is "".
+   * @brief Update Name of the input.
    * @param inID
+   * @param newName
    * @return std::string
    */
   std::string inputName(const IOIndex_t inID, std::string newName);
 
-  /*
-   * TODO: ajouter un getter de nom pour le noeud, et ajouter un tableau qui sauvegarde les nom custom
-   * Si nom custom alors tu le donne, sinon tu donne le nom par defaut en _in _out
-   */
-
-
   /**
    * @brief Get the lowest index in the InputData Parent list equal to the
    * nullptr.
@@ -289,9 +282,21 @@ public:
   std::vector<std::pair<NodePtr, IOIndex_t>>
   output(IOIndex_t outId) const;
 
+
+  /**
+   * @brief Return the output name of the Node for index.
+   * @param outId
+   * @return std::string
+   */
   std::string outputName(IOIndex_t outId) const;
 
-  //TODO: update all input of children nodes
+
+  /**
+   * @brief Update the output name of the Node for index.
+   * @param outId
+   * @param newName
+   * @return std::string
+   */
   std::string outputName(IOIndex_t outId, std::string newName);
 
   /**
diff --git a/python_binding/graph/pybind_Node.cpp b/python_binding/graph/pybind_Node.cpp
index 19eefbb41..15a0518cf 100644
--- a/python_binding/graph/pybind_Node.cpp
+++ b/python_binding/graph/pybind_Node.cpp
@@ -119,8 +119,8 @@ void init_Node(py::module& m) {
     Get ordered list of the current Node's inputs name.
     Names can be changed
 
-    :return: List of connections. When an input is not linked to any parent, the default value is (None, default_index) TODO
-    :rtype: list[tuple[Node, int]]
+    :return: List of connections names. TODO
+    :rtype: list[str]
     )mydelimiter")
 
     .def("input", &Node::input, py::arg("in_id"),
@@ -135,22 +135,24 @@ void init_Node(py::module& m) {
 
     .def("inputName", py::overload_cast<IOIndex_t>(&Node::inputName, py::const_), py::arg("in_id"),
     R"mydelimiter(
-    Get the parent Node and the associated output index connected to the i-th input of the current Node.
+    Get the name of the connection of the Node.
 
-    :param in_id: input index of the current Node object.
+    :param in_id: input index of the input Node object.
     :type in_id: int
-    :return: i-th connection. When an input is not linked to any parent, the default value is (None, default_index)
-    :rtype: tuple[Node, int]
+    :return: i-th connection name.
+    :rtype: str
     )mydelimiter")
 
     .def("inputName", py::overload_cast<IOIndex_t, std::string>(&Node::inputName), py::arg("in_id"), py::arg("newName"),
     R"mydelimiter(
-    Get the parent Node and the associated output index connected to the i-th input of the current Node.
+    Update the name of the connection Node.
 
     :param in_id: input index of the current Node object.
     :type in_id: int
-    :return: i-th connection. When an input is not linked to any parent, the default value is (None, default_index)
-    :rtype: tuple[Node, int]
+    :param newName: input index of the current Node object.
+    :type newName: str
+    :return: i-th connection new name.
+    :rtype: str
     )mydelimiter")
 
     .def("outputs", &Node::outputs,
@@ -173,32 +175,32 @@ void init_Node(py::module& m) {
 
     .def("outputsNames", &Node::outputsNames,
     R"mydelimiter(
-    Get a list of the children Node for a specific output and the associated input index connected to it.
+    Get a list of the children Node for the name of its outputs.
 
-    :param out_id: input index of the current Node object.
-    :type out_id: int
-    :return: i-th connection. When an input is not linked to any parent, the default value is (None, default_index)
-    :rtype: list[tuple[Node, int]]
+    :return: i-th connection list name.
+    :rtype: list[str]
     )mydelimiter")
 
     .def("outputName", py::overload_cast<IOIndex_t>(&Node::outputName, py::const_), py::arg("out_id"),
     R"mydelimiter(
-    Get a list of the children Node for a specific output and the associated input index connected to it.
+    Get the name of an output connection of the Node object.
 
     :param out_id: input index of the current Node object.
     :type out_id: int
-    :return: i-th connection. When an input is not linked to any parent, the default value is (None, default_index)
-    :rtype: list[tuple[Node, int]]
+    :return: i-th connection name.
+    :rtype: str
     )mydelimiter")
 
     .def("outputName", py::overload_cast<IOIndex_t, std::string>(&Node::outputName), py::arg("out_id"), py::arg("newName"),
     R"mydelimiter(
-    Get a list of the children Node for a specific output and the associated input index connected to it.
+    Update the output name of the Node object.
 
     :param out_id: input index of the current Node object.
     :type out_id: int
-    :return: i-th connection. When an input is not linked to any parent, the default value is (None, default_index)
-    :rtype: list[tuple[Node, int]]
+    :param newName: new output name
+    :type newName: str
+    :return: i-th connection new output name
+    :rtype: str
     )mydelimiter")
 
     .def("get_nb_inputs", &Node::nbInputs,
diff --git a/src/graph/Node.cpp b/src/graph/Node.cpp
index 5e50ea975..33c336a84 100644
--- a/src/graph/Node.cpp
+++ b/src/graph/Node.cpp
@@ -233,12 +233,10 @@ std::string Aidge::Node::outputName(Aidge::IOIndex_t outID) const {
 }
 
 std::string Aidge::Node::outputName(Aidge::IOIndex_t outID, std::string newName) {
-    std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>> listOutputs =
-            std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>>();
     this->mOutputNames[outID] = newName;
     for (std::size_t i = 0; i < mIdInChildren[outID].size(); ++i) {
         if (std::shared_ptr<Node> child = mChildren[outID][i].lock()) {
-            if (child && child->inputName(mIdInChildren[outID][i]) != newName) {
+            if (child->inputName(mIdInChildren[outID][i]) != newName) {
                 child->inputName(mIdInChildren[outID][i], newName);
             }
         }
-- 
GitLab