From 5349dd5b9a8f9fc70f0b5d2238fde0ecd0de3cdb Mon Sep 17 00:00:00 2001 From: Jan Kosinski Date: Sat, 27 Jun 2026 10:48:22 +0200 Subject: [PATCH 1/2] Fix: coords-to-coords score() passed kwargs that __call__ doesn't accept MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _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__). --- tme/matching_optimization.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tme/matching_optimization.py b/tme/matching_optimization.py index b67c4c64..ec804e93 100644 --- a/tme/matching_optimization.py +++ b/tme/matching_optimization.py @@ -425,10 +425,7 @@ def score(self, x: Tuple[float]) -> float: use_geometric_center=False, ) - return self( - transformed_coordinates=self.template_coordinates_rotated, - transformed_coordinates_mask=self.template_mask_coordinates_rotated, - ) + return self() class FLC(_MatchDensityToDensity): From fdc6f645efe76e75d78e0269962ddd86a7d8e710 Mon Sep 17 00:00:00 2001 From: Jan Kosinski Date: Sun, 28 Jun 2026 14:51:35 +0200 Subject: [PATCH 2/2] Add regression test: Chamfer.score() runs (coords-to-coords score() calls __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). --- tests/test_matching_optimization.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_matching_optimization.py b/tests/test_matching_optimization.py index 63a599fa..40a3ca40 100644 --- a/tests/test_matching_optimization.py +++ b/tests/test_matching_optimization.py @@ -134,6 +134,26 @@ def test_initialization(self, method: str, notest: bool = False): def test_call(self, method): self.test_initialization(method=method, notest=True)() + def _chamfer(self): + return create_score_object( + score="Chamfer", + target_coordinates=self.target_coordinates, + target_weights=self.target_weights, + template_coordinates=self.coordinates, + template_weights=self.coordinates_weights, + ) + + def test_chamfer_score_runs(self): + # _MatchCoordinatesToCoordinates.score() must call __call__ without arguments: Chamfer.__call__ + # takes none and reads self.template_coordinates_rotated written by _rigid_transform. + assert isinstance(self._chamfer().score((0, 0, 0, 0, 0, 0)), float) + + def test_chamfer_optimize_match(self): + _, _, score = optimize_match( + score_object=self._chamfer(), optimization_method="basinhopping", maxiter=1 + ) + assert isinstance(score, float) + class TestOptimizeMatch: def setup_method(self):