Skip to content

Conversation

@Grufoony
Copy link
Collaborator

@Grufoony Grufoony commented Sep 8, 2025

@Grufoony Grufoony added test Regarding the tests of the code improve Improving an already existing feature dynamics Regarding the dynamics of the system performance Regarding the performance of the code priority::high High priority stuff code refactoring examples Example simulations labels Sep 8, 2025
@Grufoony Grufoony self-assigned this Sep 8, 2025
@codecov
Copy link

codecov bot commented Sep 8, 2025

Codecov Report

❌ Patch coverage is 74.20237% with 283 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.91%. Comparing base (18482cc) to head (439914d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/dsf/headers/RoadDynamics.hpp 58.76% 127 Missing ⚠️
src/dsf/sources/RoadNetwork.cpp 68.82% 53 Missing ⚠️
src/dsf/sources/Itinerary.cpp 11.11% 32 Missing ⚠️
src/dsf/sources/AdjacencyMatrix.cpp 17.39% 19 Missing ⚠️
src/dsf/headers/Street.hpp 0.00% 11 Missing ⚠️
src/dsf/headers/RoadJunction.hpp 0.00% 10 Missing ⚠️
src/dsf/utility/Logger.hpp 28.57% 10 Missing ⚠️
src/dsf/headers/Agent.hpp 0.00% 9 Missing ⚠️
src/dsf/headers/Network.hpp 89.09% 6 Missing ⚠️
src/dsf/sources/Street.cpp 57.14% 3 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #315      +/-   ##
==========================================
- Coverage   84.25%   80.91%   -3.35%     
==========================================
  Files          39       40       +1     
  Lines        5709     5448     -261     
  Branches      574      539      -35     
==========================================
- Hits         4810     4408     -402     
- Misses        899     1040     +141     
Flag Coverage Δ
unittests 80.91% <74.20%> (-3.35%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cppcheck (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@Grufoony Grufoony force-pushed the refactorNetworkClass branch 2 times, most recently from 334db68 to 2d6f0aa Compare September 10, 2025 10:47
@Grufoony Grufoony force-pushed the refactorNetworkClass branch from 2d6f0aa to 6347dce Compare September 10, 2025 10:50
@Grufoony Grufoony marked this pull request as ready for review September 11, 2025 12:09
@Grufoony Grufoony requested a review from Copilot September 11, 2025 12:09
@Grufoony Grufoony force-pushed the refactorNetworkClass branch 4 times, most recently from 0fd6b3c to dcebff0 Compare September 12, 2025 09:45
@Grufoony Grufoony force-pushed the refactorNetworkClass branch from dcebff0 to 44f8c78 Compare September 12, 2025 13:05
@Grufoony Grufoony force-pushed the refactorNetworkClass branch from bfd0360 to 7e5c137 Compare September 12, 2025 16:18
@Grufoony Grufoony requested a review from Copilot September 12, 2025 16:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 39 out of 40 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +59 to +60
strLaneMapping +=
std::format("{} - ", directionToString[static_cast<size_t>(item)]);
Copy link

Copilot AI Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array access with static_cast could be unsafe if item is out of bounds. The directionToString array has 7 elements (indices 0-6), but there's no bounds checking before the cast and array access.

Copilot uses AI. Check for mistakes.
Comment on lines +101 to +102
Id Network<node_t, edge_t>::m_cantorHash(Id u, Id v) const {
return ((u + v) * (u + v + 1)) / 2 + v;
Copy link

Copilot AI Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Cantor pairing function could cause integer overflow for large node IDs. Consider adding overflow checks or using a larger integer type for intermediate calculations.

Copilot uses AI. Check for mistakes.
/// The first input number is the number of nodes, followed by the coordinates of each node.
/// In the i-th row of the file, the (i - 1)-th node's coordinates are expected.
void importCoordinates(const std::string& fileName);
[[deprecated]] void importCoordinates(const std::string& fileName);
Copy link

Copilot AI Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecation attribute lacks a reason or replacement suggestion. Consider adding a deprecation message like [[deprecated(\"Use addNode with coordinates instead\")]] to help users migrate.

Copilot uses AI. Check for mistakes.
@Grufoony
Copy link
Collaborator Author

However, this runs 3x slower wrt main...

@Grufoony Grufoony force-pushed the refactorNetworkClass branch from b21716e to 6d25102 Compare September 12, 2025 17:39
@Grufoony Grufoony force-pushed the refactorNetworkClass branch from 297285e to db4d08e Compare September 12, 2025 19:01
@Grufoony
Copy link
Collaborator Author

Ok I have finally found the impostor...

I think we can merge it, @sbaldu?

@Grufoony Grufoony requested a review from Copilot September 13, 2025 11:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 40 out of 41 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

gdf_edges = gdf_edges[
["osmid", "u", "v", "length", "lanes", "highway", "maxspeed", "name"]
]
gdf_edges["osmid"] = range(1, len(gdf_edges) + 1)
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The edge ID reassignment uses 1-based indexing which may cause confusion since most programming contexts use 0-based indexing. Consider using range(len(gdf_edges)) for consistency with typical array indexing patterns.

Suggested change
gdf_edges["osmid"] = range(1, len(gdf_edges) + 1)
gdf_edges["osmid"] = range(len(gdf_edges))

Copilot uses AI. Check for mistakes.
CHECK_EQ(street.angle(), 0);
street.setGeometry(std::vector<std::pair<double, double>>{{1, 0}, {0, 1}});
CHECK_EQ(street.angle(), 3 * std::numbers::pi / 4);
CHECK_EQ(street.angle(), 7 * std::numbers::pi / 4);
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The angle calculation appears incorrect. An angle of 7π/4 radians (315°) represents a direction that goes from (1,0) to (0,1), but this should be 3π/4 radians (135°) based on the coordinate change. The current value suggests a coordinate system interpretation issue.

Suggested change
CHECK_EQ(street.angle(), 7 * std::numbers::pi / 4);
CHECK_EQ(street.angle(), 3 * std::numbers::pi / 4);

Copilot uses AI. Check for mistakes.
/// The first input number is the number of nodes, followed by the coordinates of each node.
/// In the i-th row of the file, the (i - 1)-th node's coordinates are expected.
void importCoordinates(const std::string& fileName);
[[deprecated]] void importCoordinates(const std::string& fileName);
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Multiple methods are marked as deprecated without providing information about their replacements or migration path. Consider adding deprecation messages that guide users to the new APIs, e.g., [[deprecated(\"Use newMethod() instead\")]].

Suggested change
[[deprecated]] void importCoordinates(const std::string& fileName);
[[deprecated("Use importCoordinates(const std::string&) with CSV-like files instead")]] void importCoordinates(const std::string& fileName);

Copilot uses AI. Check for mistakes.
Comment on lines +101 to 103
Id Network<node_t, edge_t>::m_cantorHash(Id u, Id v) const {
return ((u + v) * (u + v + 1)) / 2 + v;
}
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Cantor pairing function can overflow for large values of u and v. Consider adding overflow checks or using a 64-bit integer type to prevent undefined behavior when the sum becomes large.

Copilot uses AI. Check for mistakes.
@Grufoony Grufoony force-pushed the refactorNetworkClass branch from ee3f643 to 439914d Compare September 13, 2025 19:09
std::format("Could not open file: {}", fileName)));
}
// Load the m_path variable from the file
inFile.read(reinterpret_cast<char*>(&m_destination), sizeof(Id));

Check warning

Code scanning / Flawfinder (reported by Codacy)

Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). Warning

Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20).
// Load the m_path variable from the file
inFile.read(reinterpret_cast<char*>(&m_destination), sizeof(Id));
size_t mapSize;
inFile.read(reinterpret_cast<char*>(&mapSize), sizeof(size_t));

Check warning

Code scanning / Flawfinder (reported by Codacy)

Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). Warning

Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20).
m_path.reserve(mapSize);
for (size_t i = 0; i < mapSize; ++i) {
Id key;
inFile.read(reinterpret_cast<char*>(&key), sizeof(Id));

Check warning

Code scanning / Flawfinder (reported by Codacy)

Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). Warning

Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20).
Id key;
inFile.read(reinterpret_cast<char*>(&key), sizeof(Id));
size_t vecSize;
inFile.read(reinterpret_cast<char*>(&vecSize), sizeof(size_t));

Check warning

Code scanning / Flawfinder (reported by Codacy)

Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). Warning

Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20).
size_t vecSize;
inFile.read(reinterpret_cast<char*>(&vecSize), sizeof(size_t));
std::vector<Id> vec(vecSize);
inFile.read(reinterpret_cast<char*>(vec.data()), vecSize * sizeof(Id));

Check warning

Code scanning / Flawfinder (reported by Codacy)

Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). Warning

Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20).
@Grufoony Grufoony merged commit dcbda37 into main Sep 15, 2025
29 of 31 checks passed
@Grufoony Grufoony deleted the refactorNetworkClass branch September 15, 2025 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code refactoring dynamics Regarding the dynamics of the system examples Example simulations improve Improving an already existing feature performance Regarding the performance of the code priority::high High priority stuff test Regarding the tests of the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make Network auto manage ids Replace Graph class with boost::graph [PROPOSAL] Add force parameter to Graph add... functions

2 participants