Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/test_matching_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 1 addition & 4 deletions tme/matching_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down