def test_scores_improve(content, style):
    """Scores must be one if inputs only vary on one dimension.
    """
    matcher = FeatureMatcher(content, style)
    matcher.compare_features_identity()
    before = matcher.repro_target.scores.sum()
    matcher.compare_features_random(times=1)
    after = matcher.repro_target.scores.sum()
    event("equal? %i" % int(after == before))
    assert after >= before
Beispiel #2
0
def test_compare_inverse_symmetrical(array):
    """Check that doing the identity comparison also projects the inverse
    coordinates into the other buffer.
    """
    matcher = FeatureMatcher(array, array)
    matcher.repro_target.from_linear(array.shape)
    matcher.repro_sources.indices.zero_()
    matcher.compare_features_identity()
    matcher.compare_features_inverse(split=1)

    assert (matcher.repro_target.indices !=
            matcher.repro_sources.indices).sum() == 0

    matcher.repro_target.indices.zero_()
    matcher.repro_target.scores.fill_(float("-inf"))
    matcher.compare_features_identity()
    matcher.compare_features_inverse(split=1)

    assert (matcher.repro_target.indices !=
            matcher.repro_sources.indices).sum() == 0
Beispiel #3
0
def test_compare_inverse_asymmetrical(content, style):
    """Check that doing the identity comparison also projects the inverse
    coordinates into the other buffer.
    """

    # Set corner pixel as identical, so it matches 100%.
    content[:, :, -1, -1] = style[:, :, -1, -1]

    matcher = FeatureMatcher(content, style)
    matcher.repro_target.from_linear(style.shape)
    matcher.repro_sources.indices.zero_()
    matcher.compare_features_identity()
    matcher.compare_features_inverse(split=2)

    assert matcher.repro_sources.indices.max() > 0

    matcher.repro_sources.from_linear(content.shape)
    matcher.repro_target.indices.zero_()
    matcher.repro_target.scores.zero_()
    matcher.compare_features_identity()
    matcher.compare_features_inverse(split=2)

    assert matcher.repro_target.indices.max() > 0