Open ggbaro opened 8 months ago
The library design is moving away from the original API idea. Therefore, it would make sense to remove the backend entirely and replace it with general functions, something like:
def get_all_matches( availabilities: pd.DataFrame, subject_col: str, slot_col: str, subjects_new_col_name: Optional[str] = None, slots_new_col_name: Optional[str] = None, ) -> pd.DataFrame: ... def select_matches( availabilities: pd.DataFrame, subjects_col: str, slots_col: str, match_scores: Optional[Iterable] = None, ) -> pd.DataFrame: ...
This way, we will have:
from swapanything import get_all_matches, select_matches import pandas as pd availabilities = [ ["KungFury", "9:00"], ["KungFury", "10:00"], ["KungFury", "13:00"], ["KungFury", "14:00"], ["Triceracop", "9:00"], ["Triceracop", "11:00"], ["Hackerman", "10:00"], ["Hackerman", "11:00"], ["Katana", "12:00"], ["Barbarianna", "12:00"], ["Thor", "13:00"], ["Thor", "14:00"], ["Thor", "15:00"], ["T-Rex", "15:00"], ["T-Rex", "16:00"], ["Hoff 9000", "16:00"], ] availabilities_df = pd.DataFrame( availabilities, columns=["subject", "availability"] ) all_possible_matches = get_all_matches( availabilities_df, "subject", "availability", "subjects", "availabilities" ) # subjects availabilities # 0 (Barbarianna, Katana) (12:00,) # 1 (Hackerman, KungFury) (10:00,) # 2 (Hackerman, Triceracop) (11:00,) # 3 (Hoff 9000, T-Rex) (16:00,) # 4 (KungFury, Thor) (13:00, 14:00) # 5 (KungFury, Triceracop) (9:00,) # 6 (T-Rex, Thor) (15:00,) select_matches(all_possible_matches, "subjects", "availabilities") # subject availability # 0 (Barbarianna, Katana) (12:00,) # 1 (Hackerman, Triceracop) (11:00,) # 2 (Hoff 9000, T-Rex) (16:00,) # 3 (KungFury, Thor) (13:00, 14:00)
Todo:
The library design is moving away from the original API idea. Therefore, it would make sense to remove the backend entirely and replace it with general functions, something like:
This way, we will have:
Todo: