def test_subtract(self, array_a, array_b, e_subtract): mask_a = Mask(array_a) mask_b = Mask(array_b) assert mask_a.subtract(mask_b) == e_subtract assert mask_a - mask_b == e_subtract assert mask_a - np.array(array_b) == e_subtract
def test_contains_mask(self, array_a, array_b, e_contains): mask_a = Mask(array_a) mask_b = Mask(array_b) array_b = np.array(array_b) assert mask_a.contains(mask_b) == e_contains assert (mask_b in mask_a) == e_contains assert mask_a.contains(array_b) == e_contains assert (array_b in mask_a) == e_contains
def test_union(self, array_a, array_b, e_union): mask_a = Mask(array_a) mask_b = Mask(array_b) assert mask_a.union(mask_b) == e_union assert mask_b.union(mask_a) == e_union assert mask_a + mask_b == e_union assert mask_a + np.array(array_b) == e_union
def test_intersect(self, array_a, array_b, e_intersect): mask_a = Mask(array_a) mask_b = Mask(array_b) assert mask_a.intersect(mask_b) == e_intersect assert mask_b.intersect(mask_a) == e_intersect assert mask_a * mask_b == e_intersect assert mask_a * np.array(array_b) == e_intersect
def test_to_polygons(self, array, e_polygons): mask = Mask(array) # order can differ depending on algo assert mask.polygons() == e_polygons
def test_to_bbox(self, array, e_bbox): mask = Mask(array) assert mask.bbox() == e_bbox
def test_contains_point(self, array, point, e_contains): mask = Mask(array) assert mask.contains(point) == e_contains assert (point in mask) == e_contains
def test_invert(self, array, e_invert): mask = Mask(array) assert ~mask == e_invert assert mask.invert() == e_invert
def test_iou(self, array_a, array_b, e_iou): mask_a = Mask(array_a) mask_b = Mask(array_b) assert mask_a.iou(mask_b) == e_iou assert mask_b.iou(mask_a) == e_iou