Skip to content

Add n_observations field to road_data table#423

Merged
Grufoony merged 2 commits intomainfrom
addNobs
Mar 10, 2026
Merged

Add n_observations field to road_data table#423
Grufoony merged 2 commits intomainfrom
addNobs

Conversation

@Grufoony
Copy link
Collaborator

Requiered by @filippodll

@Grufoony Grufoony requested a review from Copilot March 10, 2026 12:58
@Grufoony Grufoony changed the title Add n_observations fields to road_data table Add n_observations field to road_data table Mar 10, 2026
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.77%. Comparing base (32b2c65) to head (45ae5c3).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/dsf/mobility/RoadDynamics.hpp 66.66% 3 Missing ⚠️
src/dsf/utility/Measurement.hpp 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #423      +/-   ##
==========================================
- Coverage   87.78%   87.77%   -0.01%     
==========================================
  Files          52       52              
  Lines        6319     6323       +4     
  Branches      701      701              
==========================================
+ Hits         5547     5550       +3     
- Misses        753      754       +1     
  Partials       19       19              
Flag Coverage Δ
unittests 87.77% <73.33%> (-0.01%) ⬇️

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.

bool is_valid = false;

Measurement(T mean, T std) : mean{mean}, std{std}, is_valid{true} {}
Measurement() = default;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 16.3 rule Note

MISRA 16.3 rule
mean = x_mean / data.size();
std = std::sqrt(x2_mean / data.size() - mean * mean);
mean = x_mean / n;
std = std::sqrt(x2_mean / n - mean * mean);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.1 rule Note

MISRA 12.1 rule
CHECK(roadColumns.count("density_vpk") == 1);
CHECK(roadColumns.count("avg_speed_kph") == 1);
CHECK(roadColumns.count("std_speed_kph") == 1);
CHECK(roadColumns.count("n_observations") == 1);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 10.4 rule Note test

MISRA 10.4 rule
CHECK(roadColumns.count("std_speed_kph") == 1);
CHECK(roadColumns.count("n_observations") == 1);
CHECK(roadColumns.count("counts") == 1);
CHECK(roadColumns.count("queue_length") == 1);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 10.4 rule Note test

MISRA 10.4 rule
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

This PR adds an n_observations field to the road_data SQLite table and the Measurement struct, allowing consumers of the simulation data to know how many speed observations were used to compute the average and standard deviation values for each street at each time step. The Measurement struct is also refactored: the old two-argument constructor is replaced with a three-argument version that includes sample count, and a default constructor is added for invalid/empty measurements.

Changes:

  • Extended Measurement<T> with an n (sample count) field and changed the constructor from (T, T) to (T, T, std::size_t), adding a default constructor for empty/invalid measurements.
  • Added n_observations column to the road_data SQLite table schema, INSERT statement, and StreetDataRecord struct; shifted bind parameter indices accordingly.
  • Updated tests to verify the new n_observations and queue_length columns exist in the schema.

Reviewed changes

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

File Description
src/dsf/utility/Measurement.hpp Added n field, default constructor, changed 2-arg constructor to 3-arg, used n for mean/std computation.
src/dsf/mobility/RoadDynamics.hpp Added n_observations to SQL schema and INSERT, added nObservations to StreetDataRecord, updated bind indices, removed unused variable, changed empty-case returns to default-constructed Measurement.
test/mobility/Test_dynamics.cpp Added schema checks for n_observations and queue_length columns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Grufoony Grufoony merged commit 2e4ba55 into main Mar 10, 2026
43 of 45 checks passed
@Grufoony Grufoony deleted the addNobs branch March 10, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants