fatf.utils.distances.hamming_distance_base¶
-
fatf.utils.distances.hamming_distance_base(x: str, y: str, normalise: bool = False, equal_length: bool = False) → Union[int, float][source]¶ Calculates the Hamming distance between two strings
xandy.If the strings are of a different length they are compared up to the shorter one’s length and the distance between them is increased by their difference in length.
- Parameters
- xstring
The first string to be compared.
- ystring
The second string to be compared.
- normaliseboolean, optional (default=False)
Normalises the distance to be bounded between 0 and 1.
- equal_lengthboolean, optional (default=False)
Forces the arrays to be of equal length – raises exception if they are not.
- Returns
- distanceNumber
The Hamming distances between
xandy.
- Raises
- TypeError
Either
xoryis not a string.- ValueError
xandyare of different length whenequal_lengthparameter is set toTrue.