rapidfuzz / RapidFuzz

Rapid fuzzy string matching in Python using various string metrics
https://rapidfuzz.github.io/RapidFuzz/
MIT License
2.61k stars 116 forks source link

1 test fails #372

Open yurivict opened 5 months ago

yurivict commented 5 months ago
========================================================================================= FAILURES ==========================================================================================
_________________________________________________________________________________ test_large_prefix_weight __________________________________________________________________________________

    def test_large_prefix_weight():
>       assert pytest.approx(JaroWinkler.similarity('milyarder', 'milyarderlik',prefix_weight=0.5)) == 1.0

tests/distance/test_JaroWinkler.py:13: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/common.py:364: in similarity
    _, sim, _, _ = self._validate(s1, s2, catch_exceptions=catch_exceptions, **kwargs)
tests/common.py:333: in _validate
    dist = call_and_maybe_catch(self._distance, s1, s2, catch_exceptions=catch_exceptions, **kwargs)
tests/common.py:41: in call_and_maybe_catch
    return call(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.common.GenericScorer object at 0x1affcd798880>, s1 = 'milyarder', s2 = 'milyarderlik', catch_exceptions = False, kwargs = {'prefix_weight': 0.5}, symmetric = True
scores = [-0.08333333333333348, 0.0]

    def _distance(self, s1, s2, catch_exceptions=False, **kwargs):
        symmetric = self.get_scorer_flags(s1, s2, **kwargs)["symmetric"]
        tester = symmetric_scorer_tester if symmetric else scorer_tester

        scores = [
            call_and_maybe_catch(tester, scorer.distance, s1, s2, catch_exceptions=catch_exceptions, **kwargs)
            for scorer in self.scorers
        ]

        if any(isinstance(score, Exception) for score in scores):
            for score in scores:
                assert compare_exceptions(score, scores[0])
            raise scores[0]

        scores = sorted(scores)
>       assert pytest.approx(scores[0]) == scores[-1]
E       AssertionError

tests/common.py:265: AssertionError
========================================================================= 1 failed, 385 passed in 222.58s (0:03:42) =========================================================================
*** Error code 1

Version: 3.8.0 Python: 3.9 FreeBSD 14.0

maxbachmann commented 5 months ago

I forgot to update the required version of rapidfuzz-cpp in the Cmake file which is used when building against the system version of the library. So I assume you are still building against the old version of rapidfuzz-cpp which had a bug.

maxbachmann commented 5 months ago

Apparently the test for the system installation was broken and would just fallback to the non system version :sweat_smile:

With https://github.com/rapidfuzz/RapidFuzz/commit/cf788b9045ec2999c9f82cb74e5cc598a9d5dd9e it should be properly tested again

maxbachmann commented 5 months ago

I did publish a new version of the library which properly requires the latest version of rapidfuzz-cpp. Please let me know if the problem continues to occur when building rapidfuzz v3.8.1 with rapidfuzz-cpp v3.0.4

maxbachmann commented 5 months ago

Btw I had a quick look at https://github.com/freebsd/freebsd-ports/blob/main/devel/py-rapidfuzz/Makefile. 1) ${PYTHON_PKGNAMEPREFIX}rapidfuzz-capi==1.0.5:devel/py-rapidfuzz-capi@${PY_FLAVOR} \ is no longer required 2) jarowinkler-cpp>0:textproc/jarowinkler-cpp \ is no longer required 3) https://github.com/maxbachmann/RapidFuzz this is redirected by github, but could be updated to https://github.com/rapidfuzz/RapidFuzz (the same is true for https://github.com/maxbachmann/rapidfuzz-cpp) 4) I am surprised compiler:c++14-lang python is working, since the library requires C++17. I assume since rapidfuzz-cpp and taskflow require C++17 this is automatically bumped up :thinking:

maxbachmann commented 3 months ago

@yurivict was this resolved?