File: test_set_ratio.py

package info (click to toggle)
python-levenshtein 0.27.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 304 kB
  • sloc: cpp: 724; python: 291; makefile: 20; sh: 13
file content (18 lines) | stat: -rw-r--r-- 440 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from __future__ import annotations

import Levenshtein


def isclose(a, b, rel_tol=1e-09, abs_tol=0.0):
    return abs(a - b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)


def test_documented():
    """
    run tests from documentation
    """
    ratio = Levenshtein.setratio(
        ["newspaper", "litter bin", "tinny", "antelope"],
        ["caribou", "sausage", "gorn", "woody"],
    )
    assert isclose(ratio, 0.2818452380952381)