From 62f4fa5a6c4552ef1d840b0f610569fc3170e6cf Mon Sep 17 00:00:00 2001 From: Octave Perrin <operrin@lrtechnologies.fr> Date: Thu, 28 Nov 2024 15:08:56 +0100 Subject: [PATCH] back to graphview --- python_binding/graph/pybind_GraphView.cpp | 85 ++++++++++++++++++++--- 1 file changed, 74 insertions(+), 11 deletions(-) diff --git a/python_binding/graph/pybind_GraphView.cpp b/python_binding/graph/pybind_GraphView.cpp index 73f000d33..831f8c6c7 100644 --- a/python_binding/graph/pybind_GraphView.cpp +++ b/python_binding/graph/pybind_GraphView.cpp @@ -30,17 +30,80 @@ void init_GraphView(py::module& m) { :param path: save location :type path: str )mydelimiter") - .def("inputs", (std::vector<std::pair<NodePtr, IOIndex_t>> (GraphView::*)() const) &GraphView::inputs) - .def("outputs", (std::vector<std::vector<std::pair<NodePtr, IOIndex_t>>> (GraphView::*)() const) &GraphView::outputs) - .def("in_view", (bool (GraphView::*)(const NodePtr&) const) &GraphView::inView) - .def("in_view", (bool (GraphView::*)(const std::string&) const) &GraphView::inView) - .def("root_node", &GraphView::rootNode) - .def("set_root_node", &GraphView::setRootNode, py::arg("node")) - .def("__repr__", &GraphView::repr) - .def("__len__", [](const GraphView& g){ return g.getNodes().size(); }) - .def("log_outputs", &GraphView::logOutputs, py::arg("path")) - .def("get_ordered_inputs", &GraphView::getOrderedInputs) - .def("get_ordered_outputs", &GraphView::getOrderedOutputs) + + .def("inputs", (std::vector<std::pair<NodePtr, IOIndex_t>> (GraphView::*)() const) &GraphView::inputs, + R"mydelimiter( + List outside input connections of the GraphView. + The vector size is guaranteed to match the number of outside inputs of the GraphView. + If there is no external connection to a given input, a pair of nullptr and gk_IODefaultIndex is returned. + :return: A list containing the pairs Node, input indexes. + :rtype: List[Node, int] + )mydelimiter") + + .def("outputs", (std::vector<std::vector<std::pair<NodePtr, IOIndex_t>>> (GraphView::*)() const) &GraphView::outputs, + R"mydelimiter( + List outside output connections of the GraphView. + The vector size is guaranteed to match the number of outputs of the GraphView. + If there is no connection to a given output, the corresponding sub-vector will be empty. + :return: A list containing the pairs Node, output indexes. + :rtype: List[Node, int] + )mydelimiter") + + .def("in_view", (bool (GraphView::*)(const NodePtr&) const) &GraphView::inView, + R"mydelimiter( + Check that a node is in the current GraphView. + :param NodePtr: The Node that is checked + :type Node: Node that is checked + :return: True if the Node is in the GraphView, False otherwise + :rtype: bool + )mydelimiter") + + .def("in_view", (bool (GraphView::*)(const std::string&) const) &GraphView::inView, + R"mydelimiter( + Check that a node is in the current GraphView based on its name. + :param nodeName: The name of the Node that is checked + :type nodeName: Node + :return: True if the Node is in the GraphView, False otherwise + :rtype: bool + )mydelimiter") + + .def("root_node", &GraphView::rootNode, + R"mydelimiter( + Returns the rootNode of the GraphView + :return: The root Node of the GraphView + :rtype: Node + )mydelimiter") + + .def("set_root_node", &GraphView::setRootNode, py::arg("node"), + R"mydelimiter( + TODO + )mydelimiter") + + .def("__repr__", &GraphView::repr, + R"mydelimiter( + TODO + )mydelimiter") + + .def("__len__", [](const GraphView& g){ return g.getNodes().size(); }, + R"mydelimiter( + TODO + )mydelimiter") + + .def("log_outputs", &GraphView::logOutputs, py::arg("path"), + R"mydelimiter( + TODO + )mydelimiter") + + .def("get_ordered_inputs", &GraphView::getOrderedInputs, + R"mydelimiter( + TODO + )mydelimiter") + + .def("get_ordered_outputs", &GraphView::getOrderedOutputs, + R"mydelimiter( + TODO + )mydelimiter") + .def("get_output_nodes", &GraphView::outputNodes, R"mydelimiter( Get set of output Nodes. -- GitLab