diff --git a/src/kemeny_young.py b/src/kemeny_young.py index 34b4100..17b8935 100644 --- a/src/kemeny_young.py +++ b/src/kemeny_young.py @@ -23,7 +23,8 @@ from tprint import tprint def kendall_tau_dist(ranking_a: list[int], ranking_b: list[int]) -> Number: """The kendall τ distance between two rankings / permutations. - It is the number of inversions that don't have the same sign within all pairs of an inversion of ranking_a and an inversion of ranking_b. + It is the number of inversions that don't have the same sign within all + pairs of an inversion of ranking_a and an inversion of ranking_b. """ ranking_a = np.array(ranking_a) ranking_b = np.array(ranking_b) diff --git a/src/orderankings.py b/src/orderankings.py index 64a5d7b..1a5d00c 100644 --- a/src/orderankings.py +++ b/src/orderankings.py @@ -58,7 +58,7 @@ def get_orderings_from_table(table: np.ndarray, column_index: int = 0) -> list: return values[np.sort(indexes)] # distinct ordered values -def get_all_orderings_from_table(table: list[list[str]]) -> dict: +def get_all_orderings_from_table(table: list[list[str]]) -> dict[str, list[str]]: """Return a dictionnary mapping a value of the criteria to the order you get when selecting on this value. This means you get all orders of a table, where the criteria is in the diff --git a/src/tools.py b/src/tools.py index 541cfb4..3af2bce 100644 --- a/src/tools.py +++ b/src/tools.py @@ -4,7 +4,7 @@ from fastcache import lru_cache Number = int | float -# @lru_cache(maxsize=16) +@lru_cache(maxsize=4) def combinations_of_2(size: int): """Returns an array of size n*2, containing every pair of two integers smaller than size, but not listing twice the pairs with the same numbers @@ -21,7 +21,7 @@ def __combinations_of_2(size: int): """Compiled helper.""" # return np.array(list(combinations(range(size), 2))) # return np.array(np.meshgrid(np.arange(size), np.arange(size))).T.reshape(-1, 2) - return np.array([[i, j] for i in range(0, size) for j in range(0, size) if i