diff --git a/src/graph/GraphView.cpp b/src/graph/GraphView.cpp index d7a6e27fb1a739bd8b27411cf21b30bf58e2a3ad..c9f3cd14db84dab0faab065278664e68fb577db6 100644 --- a/src/graph/GraphView.cpp +++ b/src/graph/GraphView.cpp @@ -318,6 +318,7 @@ void Aidge::GraphView::setOrderedInputs(const std::vector<std::pair<NodePtr, IOI } void Aidge::GraphView::setOrderedOutputs(const std::vector<std::pair<NodePtr, IOIndex_t>>& outputs) { + // Note: one can specify any node as graph output! size_t nbOutputs = 0; std::vector<std::pair<NodePtr, IOIndex_t>> ignoredOutputs(mOutputNodes); for (auto output : outputs) { @@ -326,14 +327,13 @@ void Aidge::GraphView::setOrderedOutputs(const std::vector<std::pair<NodePtr, IO // it into account. if (output.first != nullptr) { auto it = std::find(ignoredOutputs.begin(), ignoredOutputs.end(), output); - AIDGE_ASSERT(it != ignoredOutputs.end(), "unknown or duplicate output: {} (of type {})", output.first->name(), output.first->type()); - ignoredOutputs.erase(it); + if (it != ignoredOutputs.end()) { + ignoredOutputs.erase(it); + } ++nbOutputs; } } - AIDGE_ASSERT(nbOutputs <= mOutputNodes.size(), "too many specified number of outputs: {} specified vs {} available", nbOutputs, mOutputNodes.size()); - mOutputNodes = outputs; mOutputNodes.insert(mOutputNodes.end(), ignoredOutputs.begin(), ignoredOutputs.end()); } diff --git a/unit_tests/graph/Test_GraphView.cpp b/unit_tests/graph/Test_GraphView.cpp index d9289c4aa3f4b44ce72d772c9a39dd8e66ab09e7..30071248699dbc2dd697d1d1f09c47ebcb217967 100644 --- a/unit_tests/graph/Test_GraphView.cpp +++ b/unit_tests/graph/Test_GraphView.cpp @@ -108,13 +108,6 @@ TEST_CASE("clone_with_delete", "[GraphView][cloneDelete]") { const size_t nbTests = 100; size_t nbClonedWithDelete = 0; - // Note: initial seed is chosen such that for nbTests=100, the generated - // graphs keep the same inputs/outputs despites the deleted nodes - // (meaning the deleted nodes are not input/output of the graph). - // Otherwise, the last two REQUIRE are not garanteed to be true! - // Warning: distributions are not required to behave the same way by the standard, - // therefore the seed has to work for both GCC and MSVC... - // See https://stackoverflow.com/questions/38532927/why-gcc-and-msvc-stdnormal-distribution-are-different std::mt19937::result_type seed(243); for (int test = 0; test < nbTests; ++test) { @@ -124,7 +117,21 @@ TEST_CASE("clone_with_delete", "[GraphView][cloneDelete]") { const auto g1 = std::make_shared<GraphView>("g1"); const bool unicity1 = g1->add(randGraph.gen(seed, 10)); - if (unicity1) { + bool stableInOut = true; + for (auto node : g1->inputNodes()) { + if (node->type() == "DelFictive") { + stableInOut = false; + break; + } + } + for (auto node : g1->outputNodes()) { + if (node->type() == "DelFictive") { + stableInOut = false; + break; + } + } + + if (unicity1 && stableInOut) { randGraph.omitType = "DelFictive"; const auto g2 = std::make_shared<GraphView>("g2"); const bool unicity2 = g2->add(randGraph.gen(seed, 10));