Skip to content

Conversation

@dlichy
Copy link

@dlichy dlichy commented Jun 5, 2025

This adds support for 'sequential' and 'spatial' matching strategies, in addition to the existing 'exhaustive' and 'sequential_loop' modes.

The matching mode must now be explicitly specified via the matching_mode argument instead of being inferred from window_radius.

The 'spatial' mode requires 3D locations and uses nearest-neighbor matching.

Comment on lines +232 to +237
rows = _make_pairs_spatial(['a', 'b', 'c', 'd', 'e'],num_neighbors=2, locations=[(20,0,0),(10,0,0),(5,0,0),(2,0,0), (0,0,0)])
expected = [['a', 'b', 'c'],
['b', 'c', 'd'],
['c', 'd', 'e'],
['d', 'e']]
assert rows == expected
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bit confused here: focusing on b for example it looks like

  • b gets matched with a due to ['a', 'b', 'c']
  • b gets matched with c
  • b gets matched with d due to ['b', 'c', 'd']

So b is getting matched with 3 neighbors, while num_neightbors is 2.

Is it a mistake or is there a subtlety to the interpretation of num_neighbors?

Copy link
Author

Choose a reason for hiding this comment

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

This is expected. b's two nearest neighbors are c and d. However b is also the nearest neighbor of a, so b will be matched with items a,c,d.

This lack of symmetry is better exemplified in the first test:

    rows = _make_pairs_spatial(['a', 'b', 'c', 'd', 'e'],num_neighbors=1, locations=[(20,0,0),(10,0,0),(5,0,0),(2,0,0), (0,0,0)])
    expected = [['a', 'b'],
                ['b', 'c'],
                ['c', 'd'],
                ['d', 'e']]

b is being matched with two items, a and c, even though num_neighbors=1.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, thank you I get it now

Copy link
Collaborator

@ebrahimebrahim ebrahimebrahim left a comment

Choose a reason for hiding this comment

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

Looks great!

@ebrahimebrahim ebrahimebrahim linked an issue Jun 9, 2025 that may be closed by this pull request
This adds support for 'sequential' and 'spatial' matching strategies,
in addition to the existing 'exhaustive' and 'sequential_loop' modes.

The matching mode must now be explicitly specified via the
`matching_mode` argument instead of being inferred from `window_radius`.

The 'spatial' mode requires 3D `locations` and uses nearest-neighbor matching.
@ebrahimebrahim ebrahimebrahim force-pushed the issue_333_matching_modes branch from 9c09204 to cb98331 Compare June 9, 2025 13:38
@ebrahimebrahim ebrahimebrahim enabled auto-merge (rebase) June 9, 2025 13:38
@ebrahimebrahim ebrahimebrahim merged commit e82a352 into main Jun 9, 2025
9 checks passed
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.

Meshroom support more matching modes

3 participants