File: benchmark_metrics.py

package info (click to toggle)
skimage 0.26.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 32,720 kB
  • sloc: python: 61,600; cpp: 2,592; ansic: 1,591; xml: 1,342; javascript: 1,267; makefile: 135; sh: 16
file content (28 lines) | stat: -rw-r--r-- 776 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import numpy as np

# guard against import of a non-existent metrics module in older skimage
try:
    from skimage import metrics
except ImportError:
    pass


class SetMetricsSuite:
    shape = (6, 6)
    coords_a = np.zeros(shape, dtype=bool)
    coords_b = np.zeros(shape, dtype=bool)

    def setup(self):
        points_a = (1, 0)
        points_b = (5, 2)
        self.coords_a[points_a] = True
        self.coords_b[points_b] = True

    def time_hausdorff_distance(self):
        metrics.hausdorff_distance(self.coords_a, self.coords_b)

    def time_modified_hausdorff_distance(self):
        metrics.hausdorff_distance(self.coords_a, self.coords_b, method="modified")

    def time_hausdorff_pair(self):
        metrics.hausdorff_pair(self.coords_a, self.coords_b)