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): 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):