Skip to content

feat: SE2Metric, a weight on the angle of the SE2 metric - #58

Merged
petercorke merged 2 commits into
mainfrom
feat/se2-metric
Oct 12, 2026
Merged

petercorke merged 2 commits into
mainfrom
feat/se2-metric

Conversation

@petercorke

Copy link
Copy Markdown
Owner

The built-in "SE2" metric adds radians to metres with equal weight, and there is no way to change that: in a test 144 of 300 nearest-vertex answers differed between a weight of 1 and 0.1.

SE2Metric(weight) is the same norm with the wrapped angle multiplied by a weight, the length that a radian is worth:

d = sqrt(dx² + dy² + (weight · wrap(dθ))²)
g = UGraph(dim=3, metric=SE2Metric(weight=0.5), heuristic=SE2Metric(weight=0))
  • "SE2" is SE2Metric() (weight 1), so existing results are unchanged.
  • Edge costs, closest, Vertex.distance and the A* heuristic all go through g.metric / g.heuristic, so they use the weight with no other change. A weighted L2 on a circle is still a metric, so it is a consistent heuristic when costs come from the metric; SE2Metric(weight=0) (planar distance) is the safe heuristic when costs come from elsewhere.
  • An instance pickles with its weight and compares equal by weight. SE2Metric is exported from pgraph.
  • It no longer writes into its argument (the old _SE2 assigned v[2]).

Docs: a "Distance metrics" section in construction.rst with a worked example, the metric/heuristic docstrings, and the intro.

21 new tests, including A* against uniform-cost search at four weights. 625 pass, mypy clean, docs build with no warnings.

This is the first of two PRs; the second (spatial queries, a k-d tree for closest/near) needs the weight.

🤖 Generated with Claude Code

The built-in "SE2" metric added radians to metres with equal weight, and
had no way to change it.  SE2Metric(weight) is the same norm with the
wrapped angle multiplied by a weight, the length that a radian is worth.
"SE2" is SE2Metric() so existing results do not change.  An instance is a
metric or a heuristic, is pickled with its weight, and compares equal by
weight.

Unlike the function it replaces it does not write into its argument.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 6 critical

Alerts:
⚠ 6 issues (≤ 0 issues of at least minor severity)

Results:
6 new issues

Category Results
Security 6 critical

View in Codacy

🟢 Metrics 27 complexity · 0 duplication

Metric Results
Complexity 27
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.71%. Comparing base (bc8e844) to head (4990b85).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #58      +/-   ##
==========================================
+ Coverage   96.61%   96.71%   +0.10%     
==========================================
  Files           3        3              
  Lines        1358     1371      +13     
==========================================
+ Hits         1312     1326      +14     
+ Misses         46       45       -1     

☔ View full report in Codecov by Harness.
📢 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.

@petercorke
petercorke merged commit 849c456 into main Oct 12, 2026
13 checks passed
@petercorke
petercorke deleted the feat/se2-metric branch October 12, 2026 23:04
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.

1 participant