Skip to content

Floating-point Coordinate type#908

Merged
N-Wouda merged 12 commits intomainfrom
floating-point-coords
Oct 3, 2025
Merged

Floating-point Coordinate type#908
N-Wouda merged 12 commits intomainfrom
floating-point-coords

Conversation

@N-Wouda
Copy link
Copy Markdown
Member

@N-Wouda N-Wouda commented Oct 2, 2025

This PR:

TODO:

  • Clean up
  • Retype std::pair<double, double> centroid to std::pair<Coordinate, Coordinate>
Details

Notes:

Please read our contributing guidelines first.
In particular:

  • You must add tests when making code changes.
    This keeps the code coverage level up, and helps ensure the changes work as intended.
  • When fixing a bug, you must add a test that would produce the bug in the master branch, and then show that it is fixed with the new code.
  • New code additions must be well formatted. Changes should pass the pre-commit workflow, which you can set up locally using pre-commit.
  • Docstring additions must render correctly, including escapes and LaTeX.
  • Finally, it is essential that all contributions in this PR are license-compatible with PyVRP's MIT license.
    Please check that this PR can be included into PyVRP under the MIT license.

@N-Wouda
Copy link
Copy Markdown
Member Author

N-Wouda commented Oct 2, 2025

Fairly wonky stub for this idea. Needs more work but seems to be functional already.

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 91.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.19%. Comparing base (022e18b) to head (b14babc).
⚠️ Report is 35 commits behind head on main.

Files with missing lines Patch % Lines
pyvrp/cpp/Measure.h 84.61% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #908      +/-   ##
==========================================
+ Coverage   96.17%   96.19%   +0.02%     
==========================================
  Files          79       79              
  Lines        4625     4629       +4     
  Branches     1469     1477       +8     
==========================================
+ Hits         4448     4453       +5     
  Misses         27       27              
+ Partials      150      149       -1     

☔ 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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Oct 2, 2025

CodSpeed Performance Report

Merging #908 will not alter performance

Comparing floating-point-coords (b14babc) with main (022e18b)

Summary

✅ 45 untouched

Comment on lines +222 to +224
auto const div = std::max<size_t>(size(), 1); // max 1 avoids zero div
centroid_.first += (x.get() * trip.size()) / div;
centroid_.second += (y.get() * trip.size()) / div;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this was a subtle bug, because size() can be zero for empty routes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Haha, yeah, this was bugged:

image

@N-Wouda N-Wouda marked this pull request as ready for review October 3, 2025 10:05
@N-Wouda N-Wouda requested a review from leonlan October 3, 2025 10:05
@N-Wouda N-Wouda mentioned this pull request Oct 3, 2025
@N-Wouda N-Wouda added this to the v0.12.0: Iterated local search milestone Oct 3, 2025
Copy link
Copy Markdown
Member

@leonlan leonlan left a comment

Choose a reason for hiding this comment

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

LGTM. Just one thing in the quick tutorial that we should update:

PyVRP automatically converts all numeric input values to integers. If your data has decimal values, you must scale and convert them to integers first to avoid unexpected behaviour.

I don't think we'll make any of the other parameters float anytime soon, so we can just change it like this:

PyVRP automatically converts all numeric inputs to integers, except for client x and y coordinates. If your data has decimal values, you must scale and convert them to integers first to avoid unexpected behaviour.

@N-Wouda
Copy link
Copy Markdown
Member Author

N-Wouda commented Oct 3, 2025

Forgot about the tutorial, thanks!

@N-Wouda N-Wouda merged commit 9c7f50d into main Oct 3, 2025
8 of 9 checks passed
@N-Wouda N-Wouda deleted the floating-point-coords branch October 3, 2025 12:51
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.

Allow different value types for different measures

2 participants