small visual changes

This commit is contained in:
Oscar Plaisant 2024-07-03 20:49:24 +02:00
parent 74d25bd985
commit eabe42c73f
3 changed files with 5 additions and 4 deletions

View File

@ -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)

View File

@ -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

View File

@ -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<j])
return np.array([[i, j] for i in range(size) for j in range(size) if i<j])