Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #436 +/- ##
==========================================
+ Coverage 87.33% 87.35% +0.02%
==========================================
Files 52 52
Lines 6520 6510 -10
Branches 731 730 -1
==========================================
- Hits 5694 5687 -7
+ Misses 804 801 -3
Partials 22 22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cppcheck (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
There was a problem hiding this comment.
Pull request overview
This PR updates the graph/network APIs to stop exposing std::unique_ptr<T>& (and related pointer-based call sites), switching callers to work with references/pointers to the underlying node/edge objects instead. This cascades through mobility algorithms, tests, and Python bindings, and bumps the project version.
Changes:
- Refactor
Network/RoadNetworkaccessors and path-weight callables to useT&/T const&instead ofstd::unique_ptr<T> const&. - Update mobility algorithms, tests, and bindings to use
.access and reference-based lambdas. - Bump library/version metadata to 5.3.4.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/mobility/Test_graph.cpp | Updates tests for new edge/node access patterns; adjusts path-weight lambdas. |
| test/mobility/Test_dynamics.cpp | Updates dynamics tests to use new reference-based accessors. |
| src/dsf/mobility/RoadNetwork.hpp | Updates street() return type and template constraints for weight functions. |
| src/dsf/mobility/RoadNetwork.cpp | Adapts road import/mutation logic to new accessor semantics and direct unique_ptr replacement where needed. |
| src/dsf/mobility/FirstOrderDynamics.hpp | Changes speed/weight function signatures and internal evolution helpers to work with Street const& and raw pointers. |
| src/dsf/mobility/FirstOrderDynamics.cpp | Propagates reference/pointer API changes throughout simulation evolution and path weighting. |
| src/dsf/bindings.cpp | Updates pybind lambdas to accept Street const& and use . access. |
| src/dsf/base/Network.hpp | Replaces unique_ptr-returning accessors with reference-returning accessors; updates centrality APIs accordingly. |
| src/dsf/dsf.hpp | Version patch bump to 5.3.4. |
| CITATION.cff | Updates release/version metadata to 5.3.4. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| REQUIRE(graph.edge(static_cast<Id>(0)).betweennessCentrality().has_value()); | ||
| CHECK_EQ(graph.edge(static_cast<Id>(0)).betweennessCentrality(), | ||
| doctest::Approx(3.0)); |
There was a problem hiding this comment.
Edge::betweennessCentrality() returns std::optional<double>; these CHECK_EQ lines compare the optional itself to doctest::Approx, which won’t compile / won’t test the underlying value. Dereference or use .value() (similar to how node BC is asserted above).
7bd8841 to
449a6f2
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| REQUIRE(graph.edge(static_cast<Id>(1)).betweennessCentrality().has_value()); | ||
| CHECK_EQ(graph.edge(static_cast<Id>(1)).betweennessCentrality(), | ||
| doctest::Approx(4.0)); |
There was a problem hiding this comment.
Same issue as above: after REQUIRE(...has_value()), the test should compare the contained double, not the std::optional<double> itself. Dereference or call .value() before comparing with doctest::Approx.
| REQUIRE(graph.edge(static_cast<Id>(2)).betweennessCentrality().has_value()); | ||
| CHECK_EQ(graph.edge(static_cast<Id>(2)).betweennessCentrality(), | ||
| doctest::Approx(3.0)); |
There was a problem hiding this comment.
Same issue as above: CHECK_EQ(graph.edge(...).betweennessCentrality(), doctest::Approx(...)) is comparing an std::optional<double> to an Approx. Dereference or use .value() after the REQUIRE.
| REQUIRE(graph.edge(static_cast<Id>(1)).betweennessCentrality().has_value()); | ||
| CHECK_EQ(graph.edge(static_cast<Id>(1)).betweennessCentrality(), | ||
| doctest::Approx(1.0)); |
There was a problem hiding this comment.
Same optional-vs-doctest::Approx comparison issue here: after REQUIRE(...has_value()), dereference or use .value() when comparing betweenness centrality to Approx.
| REQUIRE(graph.edge(static_cast<Id>(2)).betweennessCentrality().has_value()); | ||
| CHECK_EQ(graph.edge(static_cast<Id>(2)).betweennessCentrality(), | ||
| doctest::Approx(2.0)); |
There was a problem hiding this comment.
Same optional-vs-doctest::Approx comparison issue here: betweennessCentrality() returns std::optional<double>, so this should compare the contained double value (dereference or .value()).
| REQUIRE(graph.edge(static_cast<Id>(3)).betweennessCentrality().has_value()); | ||
| CHECK_EQ(graph.edge(static_cast<Id>(3)).betweennessCentrality(), | ||
| doctest::Approx(1.0)); |
There was a problem hiding this comment.
Same optional-vs-doctest::Approx comparison issue here: compare *...betweennessCentrality() (or .value()) instead of the std::optional<double> object.
| auto const it = std::find_if( | ||
| m_edges.cbegin(), m_edges.cend(), [source, destination](auto const& pair) { | ||
| return pair.second->source() == source && pair.second->target() == destination; | ||
| }); | ||
| if (it == m_edges.cend()) { | ||
| return nullptr; | ||
| } | ||
| return it->second.get(); |
There was a problem hiding this comment.
RoadNetwork::street() now performs a linear scan over all edges to find a (source,destination) match. Since Network::edge(source,target) already implements the same scan+throw, consider delegating to it (try/catch + return pointer) to avoid duplicated lookup logic and reduce the chance of the two implementations drifting. If lookup by (source,target) is performance-critical, consider maintaining an index map instead of scanning m_edges.
| auto const it = std::find_if( | |
| m_edges.cbegin(), m_edges.cend(), [source, destination](auto const& pair) { | |
| return pair.second->source() == source && pair.second->target() == destination; | |
| }); | |
| if (it == m_edges.cend()) { | |
| return nullptr; | |
| } | |
| return it->second.get(); | |
| try { | |
| return &edge(source, destination); | |
| } catch (std::out_of_range const&) { | |
| return nullptr; | |
| } |
449a6f2 to
fa13d1d
Compare
fa13d1d to
a53f5a3
Compare
No description provided.