예제 #1
0
def test_fullmatch_two_residual(zero, a, b):
    if fm is None:
        pytest.skip("Failed to load optional dependency %s." % missing)

    grid_1 = _fullgrid(zero, a, b, 5)

    random = np.array([
        (0.3, 0.4),
        (-0.33, 12.5),
    ])

    grid = np.vstack((grid_1, random))

    parameters = {'min_delta': 0.3, 'max_delta': 3, 'tolerance': 0.1}
    matcher = fm.FullMatcher(**parameters)
    (matches, unmatched, weak) = matcher.full_match(grid, zero=zero)

    print(matches[0])

    assert (len(matches) == 1)

    assert (len(unmatched) == len(random))
    assert (len(weak) == 0)

    match1 = matches[0]

    assert np.allclose(zero, match1.zero)
    assert (np.allclose(a, match1.a) or np.allclose(b, match1.a)
            or np.allclose(-a, match1.a) or np.allclose(-b, match1.a))
    assert (np.allclose(a, match1.b) or np.allclose(b, match1.b)
            or np.allclose(-a, match1.b) or np.allclose(-b, match1.b))
    assert (len(match1) == len(grid_1))
    assert (np.allclose(match1.calculated_refineds, grid_1))
def test_fastmatch(zero, a, b):
    grid = _fullgrid(zero, a, b, 5)
    matcher = grm.Matcher()
    match = matcher.fastmatch(centers=grid, zero=zero, a=a, b=b)
    assert (np.allclose(zero, match.zero))
    assert (np.allclose(a, match.a))
    assert (np.allclose(b, match.b))
    assert (len(match) == len(grid))
    assert (np.allclose(match.calculated_refineds, grid))
def test_affinematch(zero, a, b):
    grid = _fullgrid(zero, a, b, 5)
    indices = grm.get_indices(grid, zero, a, b)
    matcher = grm.Matcher()
    match = matcher.affinematch(centers=grid, indices=indices)
    assert (np.allclose(zero, match.zero))
    assert (np.allclose(a, match.a))
    assert (np.allclose(b, match.b))
    assert (len(match) == len(grid))
    assert (np.allclose(match.calculated_refineds, grid))
예제 #4
0
def test_fullmatch_weak(zero, a, b):
    if fm is None:
        pytest.skip("Failed to load optional dependency %s." % missing)

    grid_1 = _fullgrid(zero, a, b, 7)

    random = np.array([
        (0.3, 0.5),
    ])

    grid = np.vstack((grid_1, random))

    parameters = {
        'min_delta': 0.3,
        'max_delta': 3,
        'tolerance': 0.05,
        'min_weight': 0.1
    }

    values = np.ones(len(grid))
    elevations = np.ones(len(grid))

    # The  minimum weight is 0.1, so this should be ignored
    elevations[0] = 0.01

    matcher = fm.FullMatcher(**parameters)
    (matches, unmatched, weak) = matcher.full_match(centers=grid,
                                                    refineds=grid,
                                                    peak_values=values,
                                                    peak_elevations=elevations,
                                                    zero=zero)

    assert (len(matches) == 1)

    assert (len(unmatched) == len(random))
    assert (len(weak) == 1)

    # We have kicked out the first point with a low weight
    # so we make sure it is gone from the match although it
    # would be at the right position
    assert (len(matches[0]) == len(grid_1) - 1)
예제 #5
0
def test_fullmatch_cand(zero, a, b):
    if fm is None:
        pytest.skip("Failed to load optional dependency %s." % missing)

    grid_1 = _fullgrid(zero, a, b, 7)

    random = np.array([
        (0.3, 0.5),
    ])

    grid = np.vstack((grid_1, random))

    parameters = {'min_delta': 0.3, 'max_delta': 3, 'tolerance': 0.05}

    matcher = fm.FullMatcher(**parameters)
    (matches, unmatched,
     weak) = matcher.full_match(centers=grid,
                                zero=zero,
                                cand=[a, b, np.array((23, 42))])

    # Make sure the odd candidate didn't catch anything
    assert (len(matches) == 1)
    assert (len(unmatched) == len(random))