def test_threshold_crossing(threshold_factor, threshold_pixels, point_type, ray, raises): pg = et.PointGenerator(100, 10, threshold_factor, threshold_factor, threshold_pixels, threshold_pixels) values = np.arange(50, dtype=np.uint8) if raises: with pytest.raises(ValueError): pg.threshold_crossing(pg.xs[ray], pg.ys[ray], values, point_type) else: t = pg.get_threshold(values, pg.threshold_pixels[point_type], pg.threshold_factor[point_type]) y, x = pg.threshold_crossing(pg.xs[ray], pg.ys[ray], values, point_type) idx = np.where(pg.xs[ray] == x) if pg.above_threshold[point_type]: assert(idx == np.argmax(values[threshold_pixels:] > t) + threshold_pixels) else: assert(idx == np.argmax(values[threshold_pixels:] < t) + threshold_pixels)
def test_get_candidate_points(image, seed, above): pg = et.PointGenerator(100, 10, 1, 10) pg.get_candidate_points(image, seed, above)
def test_invalid_point_type(): pg = et.PointGenerator(100, 10, 1.5, 1.5, 10, 10) values = np.arange(50, dtype=np.uint8) with pytest.raises(ValueError): pg.threshold_crossing(pg.xs[0], pg.ys[0], values, "blah")