Skip to content

Fix coordinates-to-coordinates score() passing kwargs __call__ rejects#27

Open
jkosinski wants to merge 2 commits into
mainfrom
fix/coords-to-coords-score-call
Open

Fix coordinates-to-coordinates score() passing kwargs __call__ rejects#27
jkosinski wants to merge 2 commits into
mainfrom
fix/coords-to-coords-score-call

Conversation

@jkosinski

@jkosinski jkosinski commented Jun 27, 2026

Copy link
Copy Markdown

Problem

optimize_match on any coordinates-to-coordinates score (Chamfer, NormalVectorScore) raises:

TypeError: __call__() got an unexpected keyword argument 'transformed_coordinates'

_MatchCoordinatesToCoordinates.score() calls

return self(
    transformed_coordinates=self.template_coordinates_rotated,
    transformed_coordinates_mask=self.template_mask_coordinates_rotated,
)

but the concrete __call__ methods (Chamfer, NormalVectorScore) take no arguments — they
read self.template_coordinates_rotated, which _rigid_transform(..., out=self.template_coordinates_rotated)
has already written. So the kwargs are spurious and break the call.

Fix

Make the coordinates-to-coordinates score() call self() with no kwargs, matching the
coordinates-to-density base (_MatchCoordinatesToDensity.score, which does return self()).

Effect

Chamfer now optimises through optimize_match. NormalVectorScore still needs equal-size
pre-paired point clouds (its __call__ multiplies template_coordinates_rotated * target_coordinates
elementwise) — a separate issue, noted but not addressed here.

_MatchCoordinatesToCoordinates.score() called

    self(transformed_coordinates=..., transformed_coordinates_mask=...)

but the concrete __call__ of its subclasses (Chamfer, NormalVectorScore) take no arguments —
they read self.template_coordinates_rotated, which _rigid_transform already writes via
out=self.template_coordinates_rotated. So every optimize_match call on a coordinates-to-
coordinates score raised TypeError ("__call__() got an unexpected keyword argument
'transformed_coordinates'").

Match the coordinates-to-density base (_MatchCoordinatesToDensity.score), which calls self()
with no kwargs. Chamfer now optimises; NormalVectorScore still needs equal-size paired point
clouds (separate issue in its __call__).
…alls __call__ without args)

_MatchCoordinatesToCoordinates.score() must call __call__ without arguments -- Chamfer.__call__
takes none and reads self.template_coordinates_rotated written by _rigid_transform. Test the score
directly and through optimize_match (maxiter=1).
@jkosinski

Copy link
Copy Markdown
Author

Out of scope for this PR, noted for later: NormalVectorScore.call does not multiply its result by self.score_sign (unlike Chamfer and the other scores), so its sign convention is inconsistent. Can be fixed in a follow-up.

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